<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Module - RDoc Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="Object.html">Object</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-constants">::constants</a>
    <li ><a href="#method-c-nesting">::nesting</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-used_modules">::used_modules</a>
    <li ><a href="#method-c-used_refinements">::used_refinements</a>
    <li ><a href="#method-i-3C">#&lt;</a>
    <li ><a href="#method-i-3C-3D">#&lt;=</a>
    <li ><a href="#method-i-3C-3D-3E">#&lt;=&gt;</a>
    <li ><a href="#method-i-3D-3D">#==</a>
    <li ><a href="#method-i-3D-3D-3D">#===</a>
    <li ><a href="#method-i-3E">#&gt;</a>
    <li ><a href="#method-i-3E-3D">#&gt;=</a>
    <li ><a href="#method-i-alias_method">#alias_method</a>
    <li ><a href="#method-i-ancestors">#ancestors</a>
    <li ><a href="#method-i-append_features">#append_features</a>
    <li ><a href="#method-i-attr">#attr</a>
    <li ><a href="#method-i-attr_accessor">#attr_accessor</a>
    <li ><a href="#method-i-attr_reader">#attr_reader</a>
    <li ><a href="#method-i-attr_writer">#attr_writer</a>
    <li ><a href="#method-i-autoload">#autoload</a>
    <li ><a href="#method-i-autoload-3F">#autoload?</a>
    <li ><a href="#method-i-class_eval">#class_eval</a>
    <li ><a href="#method-i-class_exec">#class_exec</a>
    <li ><a href="#method-i-class_variable_defined-3F">#class_variable_defined?</a>
    <li ><a href="#method-i-class_variable_get">#class_variable_get</a>
    <li ><a href="#method-i-class_variable_set">#class_variable_set</a>
    <li ><a href="#method-i-class_variables">#class_variables</a>
    <li ><a href="#method-i-const_added">#const_added</a>
    <li ><a href="#method-i-const_defined-3F">#const_defined?</a>
    <li ><a href="#method-i-const_get">#const_get</a>
    <li ><a href="#method-i-const_missing">#const_missing</a>
    <li ><a href="#method-i-const_set">#const_set</a>
    <li ><a href="#method-i-const_source_location">#const_source_location</a>
    <li ><a href="#method-i-constants">#constants</a>
    <li ><a href="#method-i-define_method">#define_method</a>
    <li ><a href="#method-i-deprecate_constant">#deprecate_constant</a>
    <li ><a href="#method-i-extend_object">#extend_object</a>
    <li ><a href="#method-i-extended">#extended</a>
    <li ><a href="#method-i-freeze">#freeze</a>
    <li ><a href="#method-i-include">#include</a>
    <li ><a href="#method-i-include-3F">#include?</a>
    <li ><a href="#method-i-included">#included</a>
    <li ><a href="#method-i-included_modules">#included_modules</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-instance_method">#instance_method</a>
    <li ><a href="#method-i-instance_methods">#instance_methods</a>
    <li ><a href="#method-i-method_added">#method_added</a>
    <li ><a href="#method-i-method_defined-3F">#method_defined?</a>
    <li ><a href="#method-i-method_removed">#method_removed</a>
    <li ><a href="#method-i-method_undefined">#method_undefined</a>
    <li ><a href="#method-i-module_eval">#module_eval</a>
    <li ><a href="#method-i-module_exec">#module_exec</a>
    <li ><a href="#method-i-module_function">#module_function</a>
    <li ><a href="#method-i-name">#name</a>
    <li ><a href="#method-i-prepend">#prepend</a>
    <li ><a href="#method-i-prepend_features">#prepend_features</a>
    <li ><a href="#method-i-prepended">#prepended</a>
    <li ><a href="#method-i-private">#private</a>
    <li ><a href="#method-i-private_class_method">#private_class_method</a>
    <li ><a href="#method-i-private_constant">#private_constant</a>
    <li ><a href="#method-i-private_instance_methods">#private_instance_methods</a>
    <li ><a href="#method-i-private_method_defined-3F">#private_method_defined?</a>
    <li ><a href="#method-i-protected">#protected</a>
    <li ><a href="#method-i-protected_instance_methods">#protected_instance_methods</a>
    <li ><a href="#method-i-protected_method_defined-3F">#protected_method_defined?</a>
    <li ><a href="#method-i-public">#public</a>
    <li ><a href="#method-i-public_class_method">#public_class_method</a>
    <li ><a href="#method-i-public_constant">#public_constant</a>
    <li ><a href="#method-i-public_instance_method">#public_instance_method</a>
    <li ><a href="#method-i-public_instance_methods">#public_instance_methods</a>
    <li ><a href="#method-i-public_method_defined-3F">#public_method_defined?</a>
    <li ><a href="#method-i-refine">#refine</a>
    <li ><a href="#method-i-refinements">#refinements</a>
    <li ><a href="#method-i-remove_class_variable">#remove_class_variable</a>
    <li ><a href="#method-i-remove_const">#remove_const</a>
    <li ><a href="#method-i-remove_method">#remove_method</a>
    <li ><a href="#method-i-ruby2_keywords">#ruby2_keywords</a>
    <li ><a href="#method-i-set_temporary_name">#set_temporary_name</a>
    <li ><a href="#method-i-singleton_class-3F">#singleton_class?</a>
    <li ><a href="#method-i-to_s">#to_s</a>
    <li ><a href="#method-i-undef_method">#undef_method</a>
    <li ><a href="#method-i-undefined_instance_methods">#undefined_instance_methods</a>
    <li ><a href="#method-i-using">#using</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Module">
    <h1 id="class-Module" class="class">
      class Module
    </h1>

    <section class="description">
    
<p>A <a href="Module.html"><code>Module</code></a> is a collection of methods and constants. The methods in a module may be instance methods or module methods. Instance methods appear as methods in a class when the module is included, module methods do not. Conversely, module methods may be called without creating an encapsulating object, while instance methods may not. (See <a href="Module.html#method-i-module_function"><code>Module#module_function</code></a>.)</p>

<p>In the descriptions that follow, the parameter <em>sym</em> refers to a symbol, which is either a quoted string or a <a href="Symbol.html"><code>Symbol</code></a> (such as <code>:name</code>).</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Mod</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">Math</span>
  <span class="ruby-constant">CONST</span> = <span class="ruby-value">1</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">meth</span>
    <span class="ruby-comment">#  ...</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Mod</span>.<span class="ruby-identifier">class</span>              <span class="ruby-comment">#=&gt; Module</span>
<span class="ruby-constant">Mod</span>.<span class="ruby-identifier">constants</span>          <span class="ruby-comment">#=&gt; [:CONST, :PI, :E]</span>
<span class="ruby-constant">Mod</span>.<span class="ruby-identifier">instance_methods</span>   <span class="ruby-comment">#=&gt; [:meth]</span>
</pre>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-constants" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          constants   &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          constants(inherited)   &rarr; array
                              </span>
                            </div>

                            <div class="method-description">
                              <p>In the first form, returns an array of the names of all constants accessible from the point of call. This list includes the names of all modules and classes defined in the global scope.</p>

<pre class="ruby"><span class="ruby-constant">Module</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">first</span>(<span class="ruby-value">4</span>)
   <span class="ruby-comment"># =&gt; [:ARGF, :ARGV, :ArgumentError, :Array]</span>

<span class="ruby-constant">Module</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:SEEK_SET</span>)   <span class="ruby-comment"># =&gt; false</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">IO</span>
  <span class="ruby-constant">Module</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:SEEK_SET</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-keyword">end</span>
</pre>

<p>The second form calls the instance method <code>constants</code>.</p>

                              <div class="method-source-code" id="constants-source">
            <pre>static VALUE
rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
{
    const rb_cref_t *cref = rb_vm_cref();
    VALUE klass;
    VALUE cbase = 0;
    void *data = 0;

    if (argc &gt; 0 || mod != rb_cModule) {
        return rb_mod_constants(argc, argv, mod);
    }

    while (cref) {
        klass = CREF_CLASS(cref);
        if (!CREF_PUSHED_BY_EVAL(cref) &amp;&amp;
            !NIL_P(klass)) {
            data = rb_mod_const_at(CREF_CLASS(cref), data);
            if (!cbase) {
                cbase = klass;
            }
        }
        cref = CREF_NEXT(cref);
    }

    if (cbase) {
        data = rb_mod_const_of(cbase, data);
    }
    return rb_const_list(data);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-nesting" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          nesting    &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the list of <code>Modules</code> nested at the point of call.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">M1</span>
  <span class="ruby-keyword">module</span> <span class="ruby-constant">M2</span>
    <span class="ruby-identifier">$a</span> = <span class="ruby-constant">Module</span>.<span class="ruby-identifier">nesting</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">$a</span>           <span class="ruby-comment">#=&gt; [M1::M2, M1]</span>
<span class="ruby-identifier">$a</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">name</span>   <span class="ruby-comment">#=&gt; &quot;M1::M2&quot;</span>
</pre>

                              <div class="method-source-code" id="nesting-source">
            <pre>static VALUE
rb_mod_nesting(VALUE _)
{
    VALUE ary = rb_ary_new();
    const rb_cref_t *cref = rb_vm_cref();

    while (cref &amp;&amp; CREF_NEXT(cref)) {
        VALUE klass = CREF_CLASS(cref);
        if (!CREF_PUSHED_BY_EVAL(cref) &amp;&amp;
            !NIL_P(klass)) {
            rb_ary_push(ary, klass);
        }
        cref = CREF_NEXT(cref);
    }
    return ary;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new                  &rarr; mod
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          new {|mod| block }   &rarr; mod
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new anonymous module. If a block is given, it is passed the module object, and the block is evaluated in the context of this module like <a href="Module.html#method-i-module_eval"><code>module_eval</code></a>.</p>

<pre class="ruby"><span class="ruby-identifier">fred</span> = <span class="ruby-constant">Module</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">meth1</span>
    <span class="ruby-string">&quot;hello&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">meth2</span>
    <span class="ruby-string">&quot;bye&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">a</span> = <span class="ruby-string">&quot;my string&quot;</span>
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">extend</span>(<span class="ruby-identifier">fred</span>)   <span class="ruby-comment">#=&gt; &quot;my string&quot;</span>
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">meth1</span>          <span class="ruby-comment">#=&gt; &quot;hello&quot;</span>
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">meth2</span>          <span class="ruby-comment">#=&gt; &quot;bye&quot;</span>
</pre>

<p>Assign the module to a constant (name starting uppercase) if you want to treat it like a regular module.</p>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE
rb_mod_initialize(VALUE module)
{
    return rb_mod_initialize_exec(module);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-used_modules" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          used_modules &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of all modules used in the current scope. The ordering of modules in the resulting array is not defined.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-identifier">refine</span> <span class="ruby-constant">Object</span> <span class="ruby-keyword">do</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">module</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">refine</span> <span class="ruby-constant">Object</span> <span class="ruby-keyword">do</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">using</span> <span class="ruby-constant">A</span>
<span class="ruby-identifier">using</span> <span class="ruby-constant">B</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">Module</span>.<span class="ruby-identifier">used_modules</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby">[<span class="ruby-constant">B</span>, <span class="ruby-constant">A</span>]
</pre>

                              <div class="method-source-code" id="used_modules-source">
            <pre>static VALUE
rb_mod_s_used_modules(VALUE _)
{
    const rb_cref_t *cref = rb_vm_cref();
    VALUE ary = rb_ary_new();

    while (cref) {
        if (!NIL_P(CREF_REFINEMENTS(cref))) {
            rb_hash_foreach(CREF_REFINEMENTS(cref), used_modules_i, ary);
        }
        cref = CREF_NEXT(cref);
    }

    return rb_funcall(ary, rb_intern(&quot;uniq&quot;), 0);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-used_refinements" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          used_refinements &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of all modules used in the current scope. The ordering of modules in the resulting array is not defined.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-identifier">refine</span> <span class="ruby-constant">Object</span> <span class="ruby-keyword">do</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">module</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">refine</span> <span class="ruby-constant">Object</span> <span class="ruby-keyword">do</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">using</span> <span class="ruby-constant">A</span>
<span class="ruby-identifier">using</span> <span class="ruby-constant">B</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">Module</span>.<span class="ruby-identifier">used_refinements</span>
</pre>

<p><em>produces:</em></p>

<pre>[#&lt;refinement:Object@B&gt;, #&lt;refinement:Object@A&gt;]</pre>

                              <div class="method-source-code" id="used_refinements-source">
            <pre>static VALUE
rb_mod_s_used_refinements(VALUE _)
{
    const rb_cref_t *cref = rb_vm_cref();
    VALUE ary = rb_ary_new();

    while (cref) {
        if (!NIL_P(CREF_REFINEMENTS(cref))) {
            rb_hash_foreach(CREF_REFINEMENTS(cref), used_refinements_i, ary);
        }
        cref = CREF_NEXT(cref);
    }

    return ary;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-3C" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          mod &lt; other   &rarr;  true, false, or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if <em>mod</em> is a subclass of <em>other</em>. Returns <code>false</code> if <em>mod</em> is the same as <em>other</em> or <em>mod</em> is an ancestor of <em>other</em>. Returns <code>nil</code> if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A &lt; B” implies “A &lt; B”.)</p>

                              <div class="method-source-code" id="3C-source">
            <pre>static VALUE
rb_mod_lt(VALUE mod, VALUE arg)
{
    if (mod == arg) return Qfalse;
    return rb_class_inherited_p(mod, arg);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3C-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          mod &lt;= other   &rarr;  true, false, or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if <em>mod</em> is a subclass of <em>other</em> or is the same as <em>other</em>. Returns <code>nil</code> if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A &lt; B” implies “A &lt; B”.)</p>

                              <div class="method-source-code" id="3C-3D-source">
            <pre>VALUE
rb_class_inherited_p(VALUE mod, VALUE arg)
{
    if (mod == arg) return Qtrue;

    if (RB_TYPE_P(arg, T_CLASS) &amp;&amp; RB_TYPE_P(mod, T_CLASS)) {
        // comparison between classes
        size_t mod_depth = RCLASS_SUPERCLASS_DEPTH(mod);
        size_t arg_depth = RCLASS_SUPERCLASS_DEPTH(arg);
        if (arg_depth &lt; mod_depth) {
            // check if mod &lt; arg
            return RCLASS_SUPERCLASSES(mod)[arg_depth] == arg ?
                Qtrue :
                Qnil;
        }
        else if (arg_depth &gt; mod_depth) {
            // check if mod &gt; arg
            return RCLASS_SUPERCLASSES(arg)[mod_depth] == mod ?
                Qfalse :
                Qnil;
        }
        else {
            // Depths match, and we know they aren&#39;t equal: no relation
            return Qnil;
        }
    }
    else {
        if (!CLASS_OR_MODULE_P(arg) &amp;&amp; !RB_TYPE_P(arg, T_ICLASS)) {
            rb_raise(rb_eTypeError, &quot;compared with non class/module&quot;);
        }
        if (class_search_ancestor(mod, RCLASS_ORIGIN(arg))) {
            return Qtrue;
        }
        /* not mod &lt; arg; check if mod &gt; arg */
        if (class_search_ancestor(arg, mod)) {
            return Qfalse;
        }
        return Qnil;
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3C-3D-3E" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          module &lt;=&gt; other_module   &rarr; -1, 0, +1, or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Comparison—Returns -1, 0, +1 or nil depending on whether <code>module</code> includes <code>other_module</code>, they are the same, or if <code>module</code> is included by <code>other_module</code>.</p>

<p>Returns <code>nil</code> if <code>module</code> has no relationship with <code>other_module</code>, if <code>other_module</code> is not a module, or if the two values are incomparable.</p>

                              <div class="method-source-code" id="3C-3D-3E-source">
            <pre>static VALUE
rb_mod_cmp(VALUE mod, VALUE arg)
{
    VALUE cmp;

    if (mod == arg) return INT2FIX(0);
    if (!CLASS_OR_MODULE_P(arg)) {
        return Qnil;
    }

    cmp = rb_class_inherited_p(mod, arg);
    if (NIL_P(cmp)) return Qnil;
    if (cmp) {
        return INT2FIX(-1);
    }
    return INT2FIX(1);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          obj == other        &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          equal?(other)   &rarr; true or false
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          eql?(other)     &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Equality — At the <a href="Object.html"><code>Object</code></a> level, <a href="Module.html#method-i-3D-3D"><code>==</code></a> returns <code>true</code> only if <code>obj</code> and <code>other</code> are the same object.  Typically, this method is overridden in descendant classes to provide class-specific meaning.</p>

<p>Unlike <a href="Module.html#method-i-3D-3D"><code>==</code></a>, the <a href="BasicObject.html#method-i-equal-3F"><code>equal?</code></a> method should never be overridden by subclasses as it is used to determine object identity (that is, <code>a.equal?(b)</code> if and only if <code>a</code> is the same object as <code>b</code>):</p>

<pre class="ruby"><span class="ruby-identifier">obj</span> = <span class="ruby-string">&quot;a&quot;</span>
<span class="ruby-identifier">other</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">dup</span>

<span class="ruby-identifier">obj</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>      <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">equal?</span> <span class="ruby-identifier">other</span>  <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">equal?</span> <span class="ruby-identifier">obj</span>    <span class="ruby-comment">#=&gt; true</span>
</pre>

<p>The <a href="Object.html#method-i-eql-3F"><code>eql?</code></a> method returns <code>true</code> if <code>obj</code> and <code>other</code> refer to the same hash key.  This is used by <a href="Hash.html"><code>Hash</code></a> to test members for equality.  For any pair of objects where <a href="Object.html#method-i-eql-3F"><code>eql?</code></a> returns <code>true</code>, the <a href="Object.html#method-i-hash"><code>hash</code></a> value of both objects must be equal. So any subclass that overrides <a href="Object.html#method-i-eql-3F"><code>eql?</code></a> should also override <a href="Object.html#method-i-hash"><code>hash</code></a> appropriately.</p>

<p>For objects of class <a href="Object.html"><code>Object</code></a>, <a href="Object.html#method-i-eql-3F"><code>eql?</code></a>  is synonymous with <a href="Module.html#method-i-3D-3D"><code>==</code></a>.  Subclasses normally continue this tradition by aliasing <a href="Object.html#method-i-eql-3F"><code>eql?</code></a> to their overridden <a href="Module.html#method-i-3D-3D"><code>==</code></a> method, but there are exceptions. <a href="Numeric.html"><code>Numeric</code></a> types, for example, perform type conversion across <a href="Module.html#method-i-3D-3D"><code>==</code></a>, but not across <a href="Object.html#method-i-eql-3F"><code>eql?</code></a>, so:</p>

<pre class="ruby"><span class="ruby-value">1</span> <span class="ruby-operator">==</span> <span class="ruby-value">1.0</span>     <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-value">1</span>.<span class="ruby-identifier">eql?</span> <span class="ruby-value">1.0</span>   <span class="ruby-comment">#=&gt; false</span>
</pre>

                              <div class="method-source-code" id="3D-3D-source">
            <pre>VALUE
rb_obj_equal(VALUE obj1, VALUE obj2)
{
    return RBOOL(obj1 == obj2);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3D-3D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          mod === obj    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Case Equality—Returns <code>true</code> if <em>obj</em> is an instance of <em>mod</em> or an instance of one of <em>mod</em>’s descendants. Of limited use for modules, but can be used in <code>case</code> statements to classify objects by class.</p>

                              <div class="method-source-code" id="3D-3D-3D-source">
            <pre>static VALUE
rb_mod_eqq(VALUE mod, VALUE arg)
{
    return rb_obj_is_kind_of(arg, mod);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3E" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          mod &gt; other   &rarr;  true, false, or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if <em>mod</em> is an ancestor of <em>other</em>. Returns <code>false</code> if <em>mod</em> is the same as <em>other</em> or <em>mod</em> is a descendant of <em>other</em>. Returns <code>nil</code> if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A &lt; B” implies “B &gt; A”.)</p>

                              <div class="method-source-code" id="3E-source">
            <pre>static VALUE
rb_mod_gt(VALUE mod, VALUE arg)
{
    if (mod == arg) return Qfalse;
    return rb_mod_ge(mod, arg);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-3E-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          mod &gt;= other   &rarr;  true, false, or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if <em>mod</em> is an ancestor of <em>other</em>, or the two modules are the same. Returns <code>nil</code> if there’s no relationship between the two. (Think of the relationship in terms of the class definition: “class A &lt; B” implies “B &gt; A”.)</p>

                              <div class="method-source-code" id="3E-3D-source">
            <pre>static VALUE
rb_mod_ge(VALUE mod, VALUE arg)
{
    if (!CLASS_OR_MODULE_P(arg)) {
        rb_raise(rb_eTypeError, &quot;compared with non class/module&quot;);
    }

    return rb_class_inherited_p(arg, mod);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-alias_method" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          alias_method(new_name, old_name)   &rarr; symbol
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Makes <em>new_name</em> a new copy of the method <em>old_name</em>. This can be used to retain access to methods that are overridden.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Mod</span>
  <span class="ruby-identifier">alias_method</span> <span class="ruby-value">:orig_exit</span>, <span class="ruby-value">:exit</span> <span class="ruby-comment">#=&gt; :orig_exit</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">exit</span>(<span class="ruby-identifier">code</span>=<span class="ruby-value">0</span>)
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Exiting with code #{code}&quot;</span>
    <span class="ruby-identifier">orig_exit</span>(<span class="ruby-identifier">code</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">include</span> <span class="ruby-constant">Mod</span>
<span class="ruby-identifier">exit</span>(<span class="ruby-value">99</span>)
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Exiting</span> <span class="ruby-identifier">with</span> <span class="ruby-identifier">code</span> <span class="ruby-value">99</span>
</pre>

                              <div class="method-source-code" id="alias_method-source">
            <pre>static VALUE
rb_mod_alias_method(VALUE mod, VALUE newname, VALUE oldname)
{
    ID oldid = rb_check_id(&amp;oldname);
    if (!oldid) {
        rb_print_undef_str(mod, oldname);
    }
    VALUE id = rb_to_id(newname);
    rb_alias(mod, id, oldid);
    return ID2SYM(id);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-ancestors" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          ancestors &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a list of modules included/prepended in <em>mod</em> (including <em>mod</em> itself).</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Mod</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">Math</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">Comparable</span>
  <span class="ruby-identifier">prepend</span> <span class="ruby-constant">Enumerable</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">Mod</span>.<span class="ruby-identifier">ancestors</span>        <span class="ruby-comment">#=&gt; [Enumerable, Mod, Comparable, Math]</span>
<span class="ruby-constant">Math</span>.<span class="ruby-identifier">ancestors</span>       <span class="ruby-comment">#=&gt; [Math]</span>
<span class="ruby-constant">Enumerable</span>.<span class="ruby-identifier">ancestors</span> <span class="ruby-comment">#=&gt; [Enumerable]</span>
</pre>

                              <div class="method-source-code" id="ancestors-source">
            <pre>VALUE
rb_mod_ancestors(VALUE mod)
{
    VALUE p, ary = rb_ary_new();
    VALUE refined_class = Qnil;
    if (BUILTIN_TYPE(mod) == T_MODULE &amp;&amp; FL_TEST(mod, RMODULE_IS_REFINEMENT)) {
        refined_class = rb_refinement_module_get_refined_class(mod);
    }

    for (p = mod; p; p = RCLASS_SUPER(p)) {
        if (p == refined_class) break;
        if (p != RCLASS_ORIGIN(p)) continue;
        if (BUILTIN_TYPE(p) == T_ICLASS) {
            rb_ary_push(ary, METACLASS_OF(p));
        }
        else {
            rb_ary_push(ary, p);
        }
    }
    return ary;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-attr" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr(name, ...) &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr(name, true) &rarr; array
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr(name, false) &rarr; array
                              </span>
                            </div>

                            <div class="method-description">
                              <p>The first form is equivalent to <a href="Module.html#method-i-attr_reader"><code>attr_reader</code></a>. The second form is equivalent to <code>attr_accessor(name)</code> but deprecated. The last form is equivalent to <code>attr_reader(name)</code> but deprecated. Returns an array of defined method names as symbols.</p>

                              <div class="method-source-code" id="attr-source">
            <pre>VALUE
rb_mod_attr(int argc, VALUE *argv, VALUE klass)
{
    if (argc == 2 &amp;&amp; (argv[1] == Qtrue || argv[1] == Qfalse)) {
        ID id = id_for_attr(klass, argv[0]);
        VALUE names = rb_ary_new();

        rb_category_warning(RB_WARN_CATEGORY_DEPRECATED, &quot;optional boolean argument is obsoleted&quot;);
        rb_attr(klass, id, 1, RTEST(argv[1]), TRUE);
        rb_ary_push(names, ID2SYM(id));
        if (argv[1] == Qtrue) rb_ary_push(names, ID2SYM(rb_id_attrset(id)));
        return names;
    }
    return rb_mod_attr_reader(argc, argv, klass);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-attr_accessor" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr_accessor(symbol, ...)    &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr_accessor(string, ...)    &rarr; array
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Defines a named attribute for this module, where the name is <em>symbol.</em><code>id2name</code>, creating an instance variable (<code>@name</code>) and a corresponding access method to read it. Also creates a method called <code>name=</code> to set the attribute. <a href="String.html"><code>String</code></a> arguments are converted to symbols. Returns an array of defined method names as symbols.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Mod</span>
  <span class="ruby-identifier">attr_accessor</span>(<span class="ruby-value">:one</span>, <span class="ruby-value">:two</span>) <span class="ruby-comment">#=&gt; [:one, :one=, :two, :two=]</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Mod</span>.<span class="ruby-identifier">instance_methods</span>.<span class="ruby-identifier">sort</span>   <span class="ruby-comment">#=&gt; [:one, :one=, :two, :two=]</span>
</pre>

                              <div class="method-source-code" id="attr_accessor-source">
            <pre>static VALUE
rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass)
{
    int i;
    VALUE names = rb_ary_new2(argc * 2);

    for (i=0; i&lt;argc; i++) {
        ID id = id_for_attr(klass, argv[i]);

        rb_attr(klass, id, TRUE, TRUE, TRUE);
        rb_ary_push(names, ID2SYM(id));
        rb_ary_push(names, ID2SYM(rb_id_attrset(id)));
    }
    return names;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-attr_reader" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr_reader(symbol, ...)  &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr(symbol, ...)         &rarr; array
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr_reader(string, ...)  &rarr; array
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr(string, ...)         &rarr; array
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates instance variables and corresponding methods that return the value of each instance variable. Equivalent to calling “<code>attr</code><em>:name</em>” on each name in turn. <a href="String.html"><code>String</code></a> arguments are converted to symbols. Returns an array of defined method names as symbols.</p>

                              <div class="method-source-code" id="attr_reader-source">
            <pre>static VALUE
rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass)
{
    int i;
    VALUE names = rb_ary_new2(argc);

    for (i=0; i&lt;argc; i++) {
        ID id = id_for_attr(klass, argv[i]);
        rb_attr(klass, id, TRUE, FALSE, TRUE);
        rb_ary_push(names, ID2SYM(id));
    }
    return names;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-attr_writer" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr_writer(symbol, ...)    &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          attr_writer(string, ...)    &rarr; array
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates an accessor method to allow assignment to the attribute <em>symbol</em><code>.id2name</code>. <a href="String.html"><code>String</code></a> arguments are converted to symbols. Returns an array of defined method names as symbols.</p>

                              <div class="method-source-code" id="attr_writer-source">
            <pre>static VALUE
rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
{
    int i;
    VALUE names = rb_ary_new2(argc);

    for (i=0; i&lt;argc; i++) {
        ID id = id_for_attr(klass, argv[i]);
        rb_attr(klass, id, FALSE, TRUE, TRUE);
        rb_ary_push(names, ID2SYM(rb_id_attrset(id)));
    }
    return names;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-autoload" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          autoload(const, filename)   &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <pre>Registers _filename_ to be loaded (using Kernel::require)
the first time that _const_ (which may be a String or
a symbol) is accessed in the namespace of _mod_.

   module A
   end
   A.autoload(:B, &quot;b&quot;)
   A::B.doit            # autoloads &quot;b&quot;</pre>

<p>If <em>const</em> in <em>mod</em> is defined as autoload, the file name to be loaded is replaced with <em>filename</em>.  If <em>const</em> is defined but not as autoload, does nothing.</p>

                              <div class="method-source-code" id="autoload-source">
            <pre>static VALUE
rb_mod_autoload(VALUE mod, VALUE sym, VALUE file)
{
    ID id = rb_to_id(sym);

    FilePathValue(file);
    rb_autoload_str(mod, id, file);
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-autoload-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          autoload?(name, inherit=true)   &rarr; String or nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <em>filename</em> to be loaded if <em>name</em> is registered as <code>autoload</code> in the namespace of <em>mod</em> or one of its ancestors.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">A</span>.<span class="ruby-identifier">autoload</span>(<span class="ruby-value">:B</span>, <span class="ruby-string">&quot;b&quot;</span>)
<span class="ruby-constant">A</span>.<span class="ruby-identifier">autoload?</span>(<span class="ruby-value">:B</span>)            <span class="ruby-comment">#=&gt; &quot;b&quot;</span>
</pre>

<p>If <code>inherit</code> is false, the lookup only checks the autoloads in the receiver:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">A</span>
  <span class="ruby-identifier">autoload</span> <span class="ruby-value">:CONST</span>, <span class="ruby-string">&quot;const.rb&quot;</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">B</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">A</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">B</span>.<span class="ruby-identifier">autoload?</span>(<span class="ruby-value">:CONST</span>)          <span class="ruby-comment">#=&gt; &quot;const.rb&quot;, found in A (ancestor)</span>
<span class="ruby-constant">B</span>.<span class="ruby-identifier">autoload?</span>(<span class="ruby-value">:CONST</span>, <span class="ruby-keyword">false</span>)   <span class="ruby-comment">#=&gt; nil, not found in B itself</span>
</pre>

                              <div class="method-source-code" id="autoload-3F-source">
            <pre>static VALUE
rb_mod_autoload_p(int argc, VALUE *argv, VALUE mod)
{
    int recur = (rb_check_arity(argc, 1, 2) == 1) ? TRUE : RTEST(argv[1]);
    VALUE sym = argv[0];

    ID id = rb_check_id(&amp;sym);
    if (!id) {
        return Qnil;
    }
    return rb_autoload_at_p(mod, id, recur);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-class_eval" class="method-detail method-alias">
                      <div class="method-heading">
                        <span class="method-callseq">
                          class_eval(string [, filename [, lineno]])  &rarr; obj
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          class_eval {|mod| block }                   &rarr; obj
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates the string or block in the context of <em>mod</em>, except that when a block is given, constant/class variable lookup is not affected. This can be used to add methods to a class. <code>module_eval</code> returns the result of evaluating its argument. The optional <em>filename</em> and <em>lineno</em> parameters set the text for error messages.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Thing</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">a</span> = <span class="ruby-string">%q{def hello() &quot;Hello there!&quot; end}</span>
<span class="ruby-constant">Thing</span>.<span class="ruby-identifier">module_eval</span>(<span class="ruby-identifier">a</span>)
<span class="ruby-identifier">puts</span> <span class="ruby-constant">Thing</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">hello</span>()
<span class="ruby-constant">Thing</span>.<span class="ruby-identifier">module_eval</span>(<span class="ruby-string">&quot;invalid code&quot;</span>, <span class="ruby-string">&quot;dummy&quot;</span>, <span class="ruby-value">123</span>)
</pre>

<p><em>produces:</em></p>

<pre>Hello there!
dummy:123:in `module_eval&#39;: undefined local variable
    or method `code&#39; for Thing:Class</pre>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Module.html#method-i-module_eval">module_eval</a>
                            </div>
                          </div>

                  <div id="method-i-class_exec" class="method-detail method-alias">
                      <div class="method-heading">
                        <span class="method-callseq">
                          class_exec(arg...) {|var...| block }        &rarr; obj
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates the given block in the context of the class/module. The method defined in the block will belong to the receiver. Any arguments passed to the method will be passed to the block. This can be used if the block needs to access instance variables.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Thing</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Thing</span>.<span class="ruby-identifier">class_exec</span>{
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hello</span>() <span class="ruby-string">&quot;Hello there!&quot;</span> <span class="ruby-keyword">end</span>
}
<span class="ruby-identifier">puts</span> <span class="ruby-constant">Thing</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">hello</span>()
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Hello</span> <span class="ruby-identifier">there!</span>
</pre>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Module.html#method-i-module_exec">module_exec</a>
                            </div>
                          </div>

                  <div id="method-i-class_variable_defined-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          class_variable_defined?(symbol)    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          class_variable_defined?(string)    &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the given class variable is defined in <em>obj</em>. <a href="String.html"><code>String</code></a> arguments are converted to symbols.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Fred</span>
  <span class="ruby-identifier">@@foo</span> = <span class="ruby-value">99</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Fred</span>.<span class="ruby-identifier">class_variable_defined?</span>(<span class="ruby-value">:@@foo</span>)    <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">Fred</span>.<span class="ruby-identifier">class_variable_defined?</span>(<span class="ruby-value">:@@bar</span>)    <span class="ruby-comment">#=&gt; false</span>
</pre>

                              <div class="method-source-code" id="class_variable_defined-3F-source">
            <pre>static VALUE
rb_mod_cvar_defined(VALUE obj, VALUE iv)
{
    ID id = id_for_var(obj, iv, class);

    if (!id) {
        return Qfalse;
    }
    return rb_cvar_defined(obj, id);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-class_variable_get" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          class_variable_get(symbol)    &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          class_variable_get(string)    &rarr; obj
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns the value of the given class variable (or throws a <a href="NameError.html"><code>NameError</code></a> exception). The <code>@@</code> part of the variable name should be included for regular class variables. <a href="String.html"><code>String</code></a> arguments are converted to symbols.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Fred</span>
  <span class="ruby-identifier">@@foo</span> = <span class="ruby-value">99</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Fred</span>.<span class="ruby-identifier">class_variable_get</span>(<span class="ruby-value">:@@foo</span>)     <span class="ruby-comment">#=&gt; 99</span>
</pre>

                              <div class="method-source-code" id="class_variable_get-source">
            <pre>static VALUE
rb_mod_cvar_get(VALUE obj, VALUE iv)
{
    ID id = id_for_var(obj, iv, class);

    if (!id) {
        rb_name_err_raise(&quot;uninitialized class variable %1$s in %2$s&quot;,
                          obj, iv);
    }
    return rb_cvar_get(obj, id);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-class_variable_set" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          class_variable_set(symbol, obj)    &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          class_variable_set(string, obj)    &rarr; obj
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Sets the class variable named by <em>symbol</em> to the given object. If the class variable name is passed as a string, that string is converted to a symbol.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Fred</span>
  <span class="ruby-identifier">@@foo</span> = <span class="ruby-value">99</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">foo</span>
    <span class="ruby-identifier">@@foo</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Fred</span>.<span class="ruby-identifier">class_variable_set</span>(<span class="ruby-value">:@@foo</span>, <span class="ruby-value">101</span>)     <span class="ruby-comment">#=&gt; 101</span>
<span class="ruby-constant">Fred</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">foo</span>                             <span class="ruby-comment">#=&gt; 101</span>
</pre>

                              <div class="method-source-code" id="class_variable_set-source">
            <pre>static VALUE
rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
{
    ID id = id_for_var(obj, iv, class);
    if (!id) id = rb_intern_str(iv);
    rb_cvar_set(obj, id, val);
    return val;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-class_variables" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          class_variables(inherit=true)    &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of the names of class variables in <em>mod</em>. This includes the names of class variables in any included modules, unless the <em>inherit</em> parameter is set to <code>false</code>.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">One</span>
  <span class="ruby-identifier">@@var1</span> = <span class="ruby-value">1</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">Two</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">One</span>
  <span class="ruby-identifier">@@var2</span> = <span class="ruby-value">2</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">One</span>.<span class="ruby-identifier">class_variables</span>          <span class="ruby-comment">#=&gt; [:@@var1]</span>
<span class="ruby-constant">Two</span>.<span class="ruby-identifier">class_variables</span>          <span class="ruby-comment">#=&gt; [:@@var2, :@@var1]</span>
<span class="ruby-constant">Two</span>.<span class="ruby-identifier">class_variables</span>(<span class="ruby-keyword">false</span>)   <span class="ruby-comment">#=&gt; [:@@var2]</span>
</pre>

                              <div class="method-source-code" id="class_variables-source">
            <pre>VALUE
rb_mod_class_variables(int argc, const VALUE *argv, VALUE mod)
{
    bool inherit = true;
    st_table *tbl;

    if (rb_check_arity(argc, 0, 1)) inherit = RTEST(argv[0]);
    if (inherit) {
        tbl = mod_cvar_of(mod, 0);
    }
    else {
        tbl = mod_cvar_at(mod, 0);
    }
    return cvar_list(tbl);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-const_defined-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          const_defined?(sym, inherit=true)   &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          const_defined?(str, inherit=true)   &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Says whether <em>mod</em> or its ancestors have a constant with the given name:</p>

<pre class="ruby"><span class="ruby-constant">Float</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:EPSILON</span>)      <span class="ruby-comment">#=&gt; true, found in Float itself</span>
<span class="ruby-constant">Float</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-string">&quot;String&quot;</span>)      <span class="ruby-comment">#=&gt; true, found in Object (ancestor)</span>
<span class="ruby-constant">BasicObject</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:Hash</span>)   <span class="ruby-comment">#=&gt; false</span>
</pre>

<p>If <em>mod</em> is a <code>Module</code>, additionally <code>Object</code> and its ancestors are checked:</p>

<pre class="ruby"><span class="ruby-constant">Math</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:String</span>)   <span class="ruby-comment">#=&gt; true, found in Object</span>
</pre>

<p>In each of the checked classes or modules, if the constant is not present but there is an autoload for it, <code>true</code> is returned directly without autoloading:</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Admin</span>
  <span class="ruby-identifier">autoload</span> <span class="ruby-value">:User</span>, <span class="ruby-string">&#39;admin/user&#39;</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Admin</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:User</span>)   <span class="ruby-comment">#=&gt; true</span>
</pre>

<p>If the constant is not found the callback <code>const_missing</code> is <strong>not</strong> called and the method returns <code>false</code>.</p>

<p>If <code>inherit</code> is false, the lookup only checks the constants in the receiver:</p>

<pre class="ruby"><span class="ruby-constant">IO</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:SYNC</span>)          <span class="ruby-comment">#=&gt; true, found in File::Constants (ancestor)</span>
<span class="ruby-constant">IO</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:SYNC</span>, <span class="ruby-keyword">false</span>)   <span class="ruby-comment">#=&gt; false, not found in IO itself</span>
</pre>

<p>In this case, the same logic for autoloading applies.</p>

<p>If the argument is not a valid constant name a <code>NameError</code> is raised with the message “wrong constant name <em>name</em>”:</p>

<pre class="ruby"><span class="ruby-constant">Hash</span>.<span class="ruby-identifier">const_defined?</span> <span class="ruby-string">&#39;foobar&#39;</span>   <span class="ruby-comment">#=&gt; NameError: wrong constant name foobar</span>
</pre>

                              <div class="method-source-code" id="const_defined-3F-source">
            <pre>static VALUE
rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
{
    VALUE name, recur;
    rb_encoding *enc;
    const char *pbeg, *p, *path, *pend;
    ID id;

    rb_check_arity(argc, 1, 2);
    name = argv[0];
    recur = (argc == 1) ? Qtrue : argv[1];

    if (SYMBOL_P(name)) {
        if (!rb_is_const_sym(name)) goto wrong_name;
        id = rb_check_id(&amp;name);
        if (!id) return Qfalse;
        return RTEST(recur) ? rb_const_defined(mod, id) : rb_const_defined_at(mod, id);
    }

    path = StringValuePtr(name);
    enc = rb_enc_get(name);

    if (!rb_enc_asciicompat(enc)) {
        rb_raise(rb_eArgError, &quot;invalid class path encoding (non ASCII)&quot;);
    }

    pbeg = p = path;
    pend = path + RSTRING_LEN(name);

    if (p &gt;= pend || !*p) {
        goto wrong_name;
    }

    if (p + 2 &lt; pend &amp;&amp; p[0] == &#39;:&#39; &amp;&amp; p[1] == &#39;:&#39;) {
        mod = rb_cObject;
        p += 2;
        pbeg = p;
    }

    while (p &lt; pend) {
        VALUE part;
        long len, beglen;

        while (p &lt; pend &amp;&amp; *p != &#39;:&#39;) p++;

        if (pbeg == p) goto wrong_name;

        id = rb_check_id_cstr(pbeg, len = p-pbeg, enc);
        beglen = pbeg-path;

        if (p &lt; pend &amp;&amp; p[0] == &#39;:&#39;) {
            if (p + 2 &gt;= pend || p[1] != &#39;:&#39;) goto wrong_name;
            p += 2;
            pbeg = p;
        }

        if (!id) {
            part = rb_str_subseq(name, beglen, len);
            OBJ_FREEZE(part);
            if (!rb_is_const_name(part)) {
                name = part;
                goto wrong_name;
            }
            else {
                return Qfalse;
            }
        }
        if (!rb_is_const_id(id)) {
            name = ID2SYM(id);
            goto wrong_name;
        }

#if 0
        mod = rb_const_search(mod, id, beglen &gt; 0 || !RTEST(recur), RTEST(recur), FALSE);
        if (UNDEF_P(mod)) return Qfalse;
#else
        if (!RTEST(recur)) {
            if (!rb_const_defined_at(mod, id))
                return Qfalse;
            if (p == pend) return Qtrue;
            mod = rb_const_get_at(mod, id);
        }
        else if (beglen == 0) {
            if (!rb_const_defined(mod, id))
                return Qfalse;
            if (p == pend) return Qtrue;
            mod = rb_const_get(mod, id);
        }
        else {
            if (!rb_const_defined_from(mod, id))
                return Qfalse;
            if (p == pend) return Qtrue;
            mod = rb_const_get_from(mod, id);
        }
#endif

        if (p &lt; pend &amp;&amp; !RB_TYPE_P(mod, T_MODULE) &amp;&amp; !RB_TYPE_P(mod, T_CLASS)) {
            rb_raise(rb_eTypeError, &quot;%&quot;PRIsVALUE&quot; does not refer to class/module&quot;,
                     QUOTE(name));
        }
    }

    return Qtrue;

  wrong_name:
    rb_name_err_raise(wrong_constant_name, mod, name);
    UNREACHABLE_RETURN(Qundef);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-const_get" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          const_get(sym, inherit=true)    &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          const_get(str, inherit=true)    &rarr; obj
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Checks for a constant with the given name in <em>mod</em>. If <code>inherit</code> is set, the lookup will also search the ancestors (and <code>Object</code> if <em>mod</em> is a <code>Module</code>).</p>

<p>The value of the constant is returned if a definition is found, otherwise a <code>NameError</code> is raised.</p>

<pre class="ruby"><span class="ruby-constant">Math</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-value">:PI</span>)   <span class="ruby-comment">#=&gt; 3.14159265358979</span>
</pre>

<p>This method will recursively look up constant names if a namespaced class name is provided.  For example:</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Foo</span>; <span class="ruby-keyword">class</span> <span class="ruby-constant">Bar</span>; <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span>
<span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_get</span> <span class="ruby-string">&#39;Foo::Bar&#39;</span>
</pre>

<p>The <code>inherit</code> flag is respected on each lookup.  For example:</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Foo</span>
  <span class="ruby-keyword">class</span> <span class="ruby-constant">Bar</span>
    <span class="ruby-constant">VAL</span> = <span class="ruby-value">10</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">class</span> <span class="ruby-constant">Baz</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Bar</span>; <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_get</span> <span class="ruby-string">&#39;Foo::Baz::VAL&#39;</span>         <span class="ruby-comment"># =&gt; 10</span>
<span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_get</span> <span class="ruby-string">&#39;Foo::Baz::VAL&#39;</span>, <span class="ruby-keyword">false</span>  <span class="ruby-comment"># =&gt; NameError</span>
</pre>

<p>If the argument is not a valid constant name a <code>NameError</code> will be raised with a warning “wrong constant name”.</p>

<pre class="ruby"><span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_get</span> <span class="ruby-string">&#39;foobar&#39;</span> <span class="ruby-comment">#=&gt; NameError: wrong constant name foobar</span>
</pre>

                              <div class="method-source-code" id="const_get-source">
            <pre>static VALUE
rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
{
    VALUE name, recur;
    rb_encoding *enc;
    const char *pbeg, *p, *path, *pend;
    ID id;

    rb_check_arity(argc, 1, 2);
    name = argv[0];
    recur = (argc == 1) ? Qtrue : argv[1];

    if (SYMBOL_P(name)) {
        if (!rb_is_const_sym(name)) goto wrong_name;
        id = rb_check_id(&amp;name);
        if (!id) return rb_const_missing(mod, name);
        return RTEST(recur) ? rb_const_get(mod, id) : rb_const_get_at(mod, id);
    }

    path = StringValuePtr(name);
    enc = rb_enc_get(name);

    if (!rb_enc_asciicompat(enc)) {
        rb_raise(rb_eArgError, &quot;invalid class path encoding (non ASCII)&quot;);
    }

    pbeg = p = path;
    pend = path + RSTRING_LEN(name);

    if (p &gt;= pend || !*p) {
        goto wrong_name;
    }

    if (p + 2 &lt; pend &amp;&amp; p[0] == &#39;:&#39; &amp;&amp; p[1] == &#39;:&#39;) {
        mod = rb_cObject;
        p += 2;
        pbeg = p;
    }

    while (p &lt; pend) {
        VALUE part;
        long len, beglen;

        while (p &lt; pend &amp;&amp; *p != &#39;:&#39;) p++;

        if (pbeg == p) goto wrong_name;

        id = rb_check_id_cstr(pbeg, len = p-pbeg, enc);
        beglen = pbeg-path;

        if (p &lt; pend &amp;&amp; p[0] == &#39;:&#39;) {
            if (p + 2 &gt;= pend || p[1] != &#39;:&#39;) goto wrong_name;
            p += 2;
            pbeg = p;
        }

        if (!RB_TYPE_P(mod, T_MODULE) &amp;&amp; !RB_TYPE_P(mod, T_CLASS)) {
            rb_raise(rb_eTypeError, &quot;%&quot;PRIsVALUE&quot; does not refer to class/module&quot;,
                     QUOTE(name));
        }

        if (!id) {
            part = rb_str_subseq(name, beglen, len);
            OBJ_FREEZE(part);
            if (!rb_is_const_name(part)) {
                name = part;
                goto wrong_name;
            }
            else if (!rb_method_basic_definition_p(CLASS_OF(mod), id_const_missing)) {
                part = rb_str_intern(part);
                mod = rb_const_missing(mod, part);
                continue;
            }
            else {
                rb_mod_const_missing(mod, part);
            }
        }
        if (!rb_is_const_id(id)) {
            name = ID2SYM(id);
            goto wrong_name;
        }
#if 0
        mod = rb_const_get_0(mod, id, beglen &gt; 0 || !RTEST(recur), RTEST(recur), FALSE);
#else
        if (!RTEST(recur)) {
            mod = rb_const_get_at(mod, id);
        }
        else if (beglen == 0) {
            mod = rb_const_get(mod, id);
        }
        else {
            mod = rb_const_get_from(mod, id);
        }
#endif
    }

    return mod;

  wrong_name:
    rb_name_err_raise(wrong_constant_name, mod, name);
    UNREACHABLE_RETURN(Qundef);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-const_missing" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          const_missing(sym)    &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invoked when a reference is made to an undefined constant in <em>mod</em>. It is passed a symbol for the undefined constant, and returns a value to be used for that constant. The following code is an example of the same:</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-constant">Foo</span>.<span class="ruby-identifier ruby-title">const_missing</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">name</span> <span class="ruby-comment"># return the constant name as Symbol</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">Foo</span><span class="ruby-operator">::</span><span class="ruby-constant">UNDEFINED_CONST</span>    <span class="ruby-comment">#=&gt; :UNDEFINED_CONST: symbol returned</span>
</pre>

<p>In the next example when a reference is made to an undefined constant, it attempts to load a file whose name is the lowercase version of the constant (thus class <code>Fred</code> is assumed to be in file <code>fred.rb</code>).  If found, it returns the loaded class. It therefore implements an autoload feature similar to <a href="Kernel.html#method-i-autoload"><code>Kernel#autoload</code></a> and <a href="Module.html#method-i-autoload"><code>Module#autoload</code></a>.</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-constant">Object</span>.<span class="ruby-identifier ruby-title">const_missing</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-ivar">@looked_for</span> <span class="ruby-operator">||=</span> {}
  <span class="ruby-identifier">str_name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Class not found: #{name}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@looked_for</span>[<span class="ruby-identifier">str_name</span>]
  <span class="ruby-ivar">@looked_for</span>[<span class="ruby-identifier">str_name</span>] = <span class="ruby-value">1</span>
  <span class="ruby-identifier">file</span> = <span class="ruby-identifier">str_name</span>.<span class="ruby-identifier">downcase</span>
  <span class="ruby-identifier">require</span> <span class="ruby-identifier">file</span>
  <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">klass</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">klass</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Class not found: #{name}&quot;</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="const_missing-source">
            <pre>VALUE
rb_mod_const_missing(VALUE klass, VALUE name)
{
    rb_execution_context_t *ec = GET_EC();
    VALUE ref = ec-&gt;private_const_reference;
    rb_vm_pop_cfunc_frame();
    if (ref) {
        ec-&gt;private_const_reference = 0;
        rb_name_err_raise(&quot;private constant %2$s::%1$s referenced&quot;, ref, name);
    }
    uninitialized_constant(klass, name);

    UNREACHABLE_RETURN(Qnil);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-const_set" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          const_set(sym, obj)    &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          const_set(str, obj)    &rarr; obj
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Sets the named constant to the given object, returning that object. Creates a new constant if no constant with the given name previously existed.</p>

<pre class="ruby"><span class="ruby-constant">Math</span>.<span class="ruby-identifier">const_set</span>(<span class="ruby-string">&quot;HIGH_SCHOOL_PI&quot;</span>, <span class="ruby-value">22.0</span><span class="ruby-operator">/</span><span class="ruby-value">7.0</span>)   <span class="ruby-comment">#=&gt; 3.14285714285714</span>
<span class="ruby-constant">Math</span><span class="ruby-operator">::</span><span class="ruby-constant">HIGH_SCHOOL_PI</span> <span class="ruby-operator">-</span> <span class="ruby-constant">Math</span><span class="ruby-operator">::</span><span class="ruby-constant">PI</span>              <span class="ruby-comment">#=&gt; 0.00126448926734968</span>
</pre>

<p>If <code>sym</code> or <code>str</code> is not a valid constant name a <code>NameError</code> will be raised with a warning “wrong constant name”.</p>

<pre class="ruby"><span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_set</span>(<span class="ruby-string">&#39;foobar&#39;</span>, <span class="ruby-value">42</span>) <span class="ruby-comment">#=&gt; NameError: wrong constant name foobar</span>
</pre>

                              <div class="method-source-code" id="const_set-source">
            <pre>static VALUE
rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
{
    ID id = id_for_var(mod, name, const);
    if (!id) id = rb_intern_str(name);
    rb_const_set(mod, id, value);

    return value;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-const_source_location" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          const_source_location(sym, inherit=true)   &rarr; [String, Integer]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          const_source_location(str, inherit=true)   &rarr; [String, Integer]
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns the Ruby source filename and line number containing the definition of the constant specified. If the named constant is not found, <code>nil</code> is returned. If the constant is found, but its source location can not be extracted (constant is defined in C code), empty array is returned.</p>

<p><em>inherit</em> specifies whether to lookup in <code>mod.ancestors</code> (<code>true</code> by default).</p>

<pre class="ruby"><span class="ruby-comment"># test.rb:</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">A</span>         <span class="ruby-comment"># line 1</span>
  <span class="ruby-constant">C1</span> = <span class="ruby-value">1</span>
  <span class="ruby-constant">C2</span> = <span class="ruby-value">2</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">module</span> <span class="ruby-constant">M</span>        <span class="ruby-comment"># line 6</span>
  <span class="ruby-constant">C3</span> = <span class="ruby-value">3</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">B</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">A</span>     <span class="ruby-comment"># line 10</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">M</span>
  <span class="ruby-constant">C4</span> = <span class="ruby-value">4</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">A</span> <span class="ruby-comment"># continuation of A definition</span>
  <span class="ruby-constant">C2</span> = <span class="ruby-value">8</span> <span class="ruby-comment"># constant redefinition; warned yet allowed</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">p</span> <span class="ruby-constant">B</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;C4&#39;</span>)           <span class="ruby-comment"># =&gt; [&quot;test.rb&quot;, 12]</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">B</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;C3&#39;</span>)           <span class="ruby-comment"># =&gt; [&quot;test.rb&quot;, 7]</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">B</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;C1&#39;</span>)           <span class="ruby-comment"># =&gt; [&quot;test.rb&quot;, 2]</span>

<span class="ruby-identifier">p</span> <span class="ruby-constant">B</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;C3&#39;</span>, <span class="ruby-keyword">false</span>)    <span class="ruby-comment"># =&gt; nil  -- don&#39;t lookup in ancestors</span>

<span class="ruby-identifier">p</span> <span class="ruby-constant">A</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;C2&#39;</span>)           <span class="ruby-comment"># =&gt; [&quot;test.rb&quot;, 16] -- actual (last) definition place</span>

<span class="ruby-identifier">p</span> <span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;B&#39;</span>)       <span class="ruby-comment"># =&gt; [&quot;test.rb&quot;, 10] -- top-level constant could be looked through Object</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;A&#39;</span>)       <span class="ruby-comment"># =&gt; [&quot;test.rb&quot;, 1] -- class reopening is NOT considered new definition</span>

<span class="ruby-identifier">p</span> <span class="ruby-constant">B</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;A&#39;</span>)            <span class="ruby-comment"># =&gt; [&quot;test.rb&quot;, 1]  -- because Object is in ancestors</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">M</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;A&#39;</span>)            <span class="ruby-comment"># =&gt; [&quot;test.rb&quot;, 1]  -- Object is not ancestor, but additionally checked for modules</span>

<span class="ruby-identifier">p</span> <span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;A::C1&#39;</span>)   <span class="ruby-comment"># =&gt; [&quot;test.rb&quot;, 2]  -- nesting is supported</span>
<span class="ruby-identifier">p</span> <span class="ruby-constant">Object</span>.<span class="ruby-identifier">const_source_location</span>(<span class="ruby-string">&#39;String&#39;</span>)  <span class="ruby-comment"># =&gt; []  -- constant is defined in C code</span>
</pre>

                              <div class="method-source-code" id="const_source_location-source">
            <pre>static VALUE
rb_mod_const_source_location(int argc, VALUE *argv, VALUE mod)
{
    VALUE name, recur, loc = Qnil;
    rb_encoding *enc;
    const char *pbeg, *p, *path, *pend;
    ID id;

    rb_check_arity(argc, 1, 2);
    name = argv[0];
    recur = (argc == 1) ? Qtrue : argv[1];

    if (SYMBOL_P(name)) {
        if (!rb_is_const_sym(name)) goto wrong_name;
        id = rb_check_id(&amp;name);
        if (!id) return Qnil;
        return RTEST(recur) ? rb_const_source_location(mod, id) : rb_const_source_location_at(mod, id);
    }

    path = StringValuePtr(name);
    enc = rb_enc_get(name);

    if (!rb_enc_asciicompat(enc)) {
        rb_raise(rb_eArgError, &quot;invalid class path encoding (non ASCII)&quot;);
    }

    pbeg = p = path;
    pend = path + RSTRING_LEN(name);

    if (p &gt;= pend || !*p) {
        goto wrong_name;
    }

    if (p + 2 &lt; pend &amp;&amp; p[0] == &#39;:&#39; &amp;&amp; p[1] == &#39;:&#39;) {
        mod = rb_cObject;
        p += 2;
        pbeg = p;
    }

    while (p &lt; pend) {
        VALUE part;
        long len, beglen;

        while (p &lt; pend &amp;&amp; *p != &#39;:&#39;) p++;

        if (pbeg == p) goto wrong_name;

        id = rb_check_id_cstr(pbeg, len = p-pbeg, enc);
        beglen = pbeg-path;

        if (p &lt; pend &amp;&amp; p[0] == &#39;:&#39;) {
            if (p + 2 &gt;= pend || p[1] != &#39;:&#39;) goto wrong_name;
            p += 2;
            pbeg = p;
        }

        if (!id) {
            part = rb_str_subseq(name, beglen, len);
            OBJ_FREEZE(part);
            if (!rb_is_const_name(part)) {
                name = part;
                goto wrong_name;
            }
            else {
                return Qnil;
            }
        }
        if (!rb_is_const_id(id)) {
            name = ID2SYM(id);
            goto wrong_name;
        }
        if (p &lt; pend) {
            if (RTEST(recur)) {
                mod = rb_const_get(mod, id);
            }
            else {
                mod = rb_const_get_at(mod, id);
            }
            if (!RB_TYPE_P(mod, T_MODULE) &amp;&amp; !RB_TYPE_P(mod, T_CLASS)) {
                rb_raise(rb_eTypeError, &quot;%&quot;PRIsVALUE&quot; does not refer to class/module&quot;,
                         QUOTE(name));
            }
        }
        else {
            if (RTEST(recur)) {
                loc = rb_const_source_location(mod, id);
            }
            else {
                loc = rb_const_source_location_at(mod, id);
            }
            break;
        }
        recur = Qfalse;
    }

    return loc;

  wrong_name:
    rb_name_err_raise(wrong_constant_name, mod, name);
    UNREACHABLE_RETURN(Qundef);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-constants" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          constants(inherit=true)    &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of the names of the constants accessible in <em>mod</em>. This includes the names of constants in any included modules (example at start of section), unless the <em>inherit</em> parameter is set to <code>false</code>.</p>

<p>The implementation makes no guarantees about the order in which the constants are yielded.</p>

<pre class="ruby"><span class="ruby-constant">IO</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:SYNC</span>)        <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">IO</span>.<span class="ruby-identifier">constants</span>(<span class="ruby-keyword">false</span>).<span class="ruby-identifier">include?</span>(<span class="ruby-value">:SYNC</span>) <span class="ruby-comment">#=&gt; false</span>
</pre>

<p>Also see <a href="Module.html#method-i-const_defined-3F"><code>Module#const_defined?</code></a>.</p>

                              <div class="method-source-code" id="constants-source">
            <pre>VALUE
rb_mod_constants(int argc, const VALUE *argv, VALUE mod)
{
    bool inherit = true;

    if (rb_check_arity(argc, 0, 1)) inherit = RTEST(argv[0]);

    if (inherit) {
        return rb_const_list(rb_mod_const_of(mod, 0));
    }
    else {
        return rb_local_constants(mod);
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-define_method" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          define_method(symbol, method)     &rarr; symbol
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          define_method(symbol) { block }   &rarr; symbol
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Defines an instance method in the receiver. The <em>method</em> parameter can be a <code>Proc</code>, a <code>Method</code> or an <code>UnboundMethod</code> object. If a block is specified, it is used as the method body. If a block or the <em>method</em> parameter has parameters, they’re used as method parameters. This block is evaluated using <a href="BasicObject.html#method-i-instance_eval"><code>instance_eval</code></a>.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fred</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;In Fred&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">create_method</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">define_method</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">define_method</span>(<span class="ruby-value">:wilma</span>) { <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Charge it!&quot;</span> }
  <span class="ruby-identifier">define_method</span>(<span class="ruby-value">:flint</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;I&#39;m #{name}!&quot;</span>}
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">B</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">A</span>
  <span class="ruby-identifier">define_method</span>(<span class="ruby-value">:barney</span>, <span class="ruby-identifier">instance_method</span>(<span class="ruby-value">:fred</span>))
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">a</span> = <span class="ruby-constant">B</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">barney</span>
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">wilma</span>
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">flint</span>(<span class="ruby-string">&#39;Dino&#39;</span>)
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">create_method</span>(<span class="ruby-value">:betty</span>) { <span class="ruby-identifier">p</span> <span class="ruby-keyword">self</span> }
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">betty</span>
</pre>

<p><em>produces:</em></p>

<pre>In Fred
Charge it!
I&#39;m Dino!
#&lt;B:0x401b39e8&gt;</pre>

                              <div class="method-source-code" id="define_method-source">
            <pre>static VALUE
rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
{
    const rb_cref_t *cref = rb_vm_cref_in_context(mod, mod);
    const rb_scope_visibility_t default_scope_visi = {METHOD_VISI_PUBLIC, FALSE};
    const rb_scope_visibility_t *scope_visi = &amp;default_scope_visi;

    if (cref) {
        scope_visi = CREF_SCOPE_VISI(cref);
    }

    return rb_mod_define_method_with_visibility(argc, argv, mod, scope_visi);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-deprecate_constant" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          deprecate_constant(symbol, ...)    &rarr; mod
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Makes a list of existing constants deprecated. Attempt to refer to them will produce a warning.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">HTTP</span>
  <span class="ruby-constant">NotFound</span> = <span class="ruby-constant">Exception</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-constant">NOT_FOUND</span> = <span class="ruby-constant">NotFound</span> <span class="ruby-comment"># previous version of the library used this name</span>

  <span class="ruby-identifier">deprecate_constant</span> <span class="ruby-value">:NOT_FOUND</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">NOT_FOUND</span>
<span class="ruby-comment"># warning: constant HTTP::NOT_FOUND is deprecated</span>
</pre>

                              <div class="method-source-code" id="deprecate_constant-source">
            <pre>VALUE
rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj)
{
    set_const_visibility(obj, argc, argv, CONST_DEPRECATED, CONST_DEPRECATED);
    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-freeze" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          freeze       &rarr; mod
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Prevents further modifications to <em>mod</em>.</p>

<p>This method returns self.</p>

                              <div class="method-source-code" id="freeze-source">
            <pre>static VALUE
rb_mod_freeze(VALUE mod)
{
    rb_class_name(mod);
    return rb_obj_freeze(mod);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-include" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          include(module, ...)    &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invokes <a href="Module.html#method-i-append_features"><code>Module.append_features</code></a> on each parameter in reverse order.</p>

                              <div class="method-source-code" id="include-source">
            <pre>static VALUE
rb_mod_include(int argc, VALUE *argv, VALUE module)
{
    int i;
    ID id_append_features, id_included;

    CONST_ID(id_append_features, &quot;append_features&quot;);
    CONST_ID(id_included, &quot;included&quot;);

    if (BUILTIN_TYPE(module) == T_MODULE &amp;&amp; FL_TEST(module, RMODULE_IS_REFINEMENT)) {
        rb_raise(rb_eTypeError, &quot;Refinement#include has been removed&quot;);
    }

    rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
    for (i = 0; i &lt; argc; i++) {
        Check_Type(argv[i], T_MODULE);
        if (FL_TEST(argv[i], RMODULE_IS_REFINEMENT)) {
            rb_raise(rb_eTypeError, &quot;Cannot include refinement&quot;);
        }
    }
    while (argc--) {
        rb_funcall(argv[argc], id_append_features, 1, module);
        rb_funcall(argv[argc], id_included, 1, module);
    }
    return module;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-include-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          include?(module)    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <em>module</em> is included or prepended in <em>mod</em> or one of <em>mod</em>’s ancestors.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">A</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">C</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">B</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">B</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">A</span>)   <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">A</span>)   <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">A</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">A</span>)   <span class="ruby-comment">#=&gt; false</span>
</pre>

                              <div class="method-source-code" id="include-3F-source">
            <pre>VALUE
rb_mod_include_p(VALUE mod, VALUE mod2)
{
    VALUE p;

    Check_Type(mod2, T_MODULE);
    for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
        if (BUILTIN_TYPE(p) == T_ICLASS &amp;&amp; !FL_TEST(p, RICLASS_IS_ORIGIN)) {
            if (METACLASS_OF(p) == mod2) return Qtrue;
        }
    }
    return Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-included_modules" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          included_modules &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the list of modules included or prepended in <em>mod</em> or one of <em>mod</em>’s ancestors.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Sub</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">module</span> <span class="ruby-constant">Mixin</span>
  <span class="ruby-identifier">prepend</span> <span class="ruby-constant">Sub</span>
<span class="ruby-keyword">end</span>

<span class="ruby-keyword">module</span> <span class="ruby-constant">Outer</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">Mixin</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">Mixin</span>.<span class="ruby-identifier">included_modules</span>   <span class="ruby-comment">#=&gt; [Sub]</span>
<span class="ruby-constant">Outer</span>.<span class="ruby-identifier">included_modules</span>   <span class="ruby-comment">#=&gt; [Sub, Mixin]</span>
</pre>

                              <div class="method-source-code" id="included_modules-source">
            <pre>VALUE
rb_mod_included_modules(VALUE mod)
{
    VALUE ary = rb_ary_new();
    VALUE p;
    VALUE origin = RCLASS_ORIGIN(mod);

    for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
        if (p != origin &amp;&amp; RCLASS_ORIGIN(p) == p &amp;&amp; BUILTIN_TYPE(p) == T_ICLASS) {
            VALUE m = METACLASS_OF(p);
            if (RB_TYPE_P(m, T_MODULE))
                rb_ary_push(ary, m);
        }
    }
    return ary;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">inspect</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string representing this module or class. For basic classes and modules, this is the name. For singletons, we show information on the thing we’re attached to as well.</p>

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Module.html#method-i-to_s">to_s</a>
                            </div>
                          </div>

                  <div id="method-i-instance_method" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          instance_method(symbol)   &rarr; unbound_method
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an <code>UnboundMethod</code> representing the given instance method in <em>mod</em>.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Interpreter</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">do_a</span>() <span class="ruby-identifier">print</span> <span class="ruby-string">&quot;there, &quot;</span>; <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">do_d</span>() <span class="ruby-identifier">print</span> <span class="ruby-string">&quot;Hello &quot;</span>;  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">do_e</span>() <span class="ruby-identifier">print</span> <span class="ruby-string">&quot;!\n&quot;</span>;     <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">do_v</span>() <span class="ruby-identifier">print</span> <span class="ruby-string">&quot;Dave&quot;</span>;    <span class="ruby-keyword">end</span>
  <span class="ruby-constant">Dispatcher</span> = {
    <span class="ruby-string">&quot;a&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">instance_method</span>(<span class="ruby-value">:do_a</span>),
    <span class="ruby-string">&quot;d&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">instance_method</span>(<span class="ruby-value">:do_d</span>),
    <span class="ruby-string">&quot;e&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">instance_method</span>(<span class="ruby-value">:do_e</span>),
    <span class="ruby-string">&quot;v&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">instance_method</span>(<span class="ruby-value">:do_v</span>)
  }
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">interpret</span>(<span class="ruby-identifier">string</span>)
    <span class="ruby-identifier">string</span>.<span class="ruby-identifier">each_char</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-constant">Dispatcher</span>[<span class="ruby-identifier">b</span>].<span class="ruby-identifier">bind</span>(<span class="ruby-keyword">self</span>).<span class="ruby-identifier">call</span> }
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">interpreter</span> = <span class="ruby-constant">Interpreter</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">interpreter</span>.<span class="ruby-identifier">interpret</span>(<span class="ruby-string">&#39;dave&#39;</span>)
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Hello</span> <span class="ruby-identifier">there</span>, <span class="ruby-identifier">Dave!</span>
</pre>

                              <div class="method-source-code" id="instance_method-source">
            <pre>static VALUE
rb_mod_instance_method(VALUE mod, VALUE vid)
{
    ID id = rb_check_id(&amp;vid);
    if (!id) {
        rb_method_name_error(mod, vid);
    }
    return mnew_unbound(mod, id, rb_cUnboundMethod, FALSE);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-instance_methods" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          instance_methods(include_super=true)   &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array containing the names of the public and protected instance methods in the receiver. For a module, these are the public and protected methods; for a class, they are the instance (not singleton) methods. If the optional parameter is <code>false</code>, the methods of any ancestors are not included.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method1</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method2</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">C</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">B</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method3</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">A</span>.<span class="ruby-identifier">instance_methods</span>(<span class="ruby-keyword">false</span>)                   <span class="ruby-comment">#=&gt; [:method1]</span>
<span class="ruby-constant">B</span>.<span class="ruby-identifier">instance_methods</span>(<span class="ruby-keyword">false</span>)                   <span class="ruby-comment">#=&gt; [:method2]</span>
<span class="ruby-constant">B</span>.<span class="ruby-identifier">instance_methods</span>(<span class="ruby-keyword">true</span>).<span class="ruby-identifier">include?</span>(<span class="ruby-value">:method1</span>) <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">instance_methods</span>(<span class="ruby-keyword">false</span>)                   <span class="ruby-comment">#=&gt; [:method3]</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">instance_methods</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value">:method2</span>)       <span class="ruby-comment">#=&gt; true</span>
</pre>

<p>Note that method visibility changes in the current class, as well as aliases, are considered as methods of the current class by this method:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">C</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">B</span>
  <span class="ruby-keyword">alias</span> <span class="ruby-identifier">method4</span> <span class="ruby-identifier">method2</span>
  <span class="ruby-identifier">protected</span> <span class="ruby-value">:method2</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">instance_methods</span>(<span class="ruby-keyword">false</span>).<span class="ruby-identifier">sort</span>               <span class="ruby-comment">#=&gt; [:method2, :method3, :method4]</span>
</pre>

                              <div class="method-source-code" id="instance_methods-source">
            <pre>VALUE
rb_class_instance_methods(int argc, const VALUE *argv, VALUE mod)
{
    return class_instance_method_list(argc, argv, mod, 0, ins_methods_i);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-method_defined-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          method_defined?(symbol, inherit=true)    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          method_defined?(string, inherit=true)    &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the named method is defined by <em>mod</em>.  If <em>inherit</em> is set, the lookup will also search <em>mod</em>’s ancestors. Public and protected methods are matched. <a href="String.html"><code>String</code></a> arguments are converted to symbols.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method1</span>()  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">protected_method1</span>()  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">protected</span> <span class="ruby-value">:protected_method1</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">B</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method2</span>()  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">private_method2</span>()  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">private</span> <span class="ruby-value">:private_method2</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">C</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method3</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">A</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-value">:method1</span>              <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;method1&quot;</span>             <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>             <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>, <span class="ruby-keyword">true</span>       <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>, <span class="ruby-keyword">false</span>      <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;method3&quot;</span>             <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;protected_method1&quot;</span>   <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;method4&quot;</span>             <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;private_method2&quot;</span>     <span class="ruby-comment">#=&gt; false</span>
</pre>

                              <div class="method-source-code" id="method_defined-3F-source">
            <pre>static VALUE
rb_mod_method_defined(int argc, VALUE *argv, VALUE mod)
{
    rb_method_visibility_t visi = check_definition_visibility(mod, argc, argv);
    return RBOOL(visi == METHOD_VISI_PUBLIC || visi == METHOD_VISI_PROTECTED);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-module_eval" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          module_eval(string [, filename [, lineno]]) &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          module_eval {|mod| block }                  &rarr; obj
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates the string or block in the context of <em>mod</em>, except that when a block is given, constant/class variable lookup is not affected. This can be used to add methods to a class. <code>module_eval</code> returns the result of evaluating its argument. The optional <em>filename</em> and <em>lineno</em> parameters set the text for error messages.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Thing</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">a</span> = <span class="ruby-string">%q{def hello() &quot;Hello there!&quot; end}</span>
<span class="ruby-constant">Thing</span>.<span class="ruby-identifier">module_eval</span>(<span class="ruby-identifier">a</span>)
<span class="ruby-identifier">puts</span> <span class="ruby-constant">Thing</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">hello</span>()
<span class="ruby-constant">Thing</span>.<span class="ruby-identifier">module_eval</span>(<span class="ruby-string">&quot;invalid code&quot;</span>, <span class="ruby-string">&quot;dummy&quot;</span>, <span class="ruby-value">123</span>)
</pre>

<p><em>produces:</em></p>

<pre>Hello there!
dummy:123:in `module_eval&#39;: undefined local variable
    or method `code&#39; for Thing:Class</pre>

                              <div class="method-source-code" id="module_eval-source">
            <pre>static VALUE
rb_mod_module_eval_internal(int argc, const VALUE *argv, VALUE mod)
{
    return specific_eval(argc, argv, mod, FALSE, RB_PASS_CALLED_KEYWORDS);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Module.html#method-i-class_eval">class_eval</a>
                            </div>

                          </div>

                  <div id="method-i-module_exec" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          module_exec(arg...) {|var...| block }       &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates the given block in the context of the class/module. The method defined in the block will belong to the receiver. Any arguments passed to the method will be passed to the block. This can be used if the block needs to access instance variables.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Thing</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Thing</span>.<span class="ruby-identifier">class_exec</span>{
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hello</span>() <span class="ruby-string">&quot;Hello there!&quot;</span> <span class="ruby-keyword">end</span>
}
<span class="ruby-identifier">puts</span> <span class="ruby-constant">Thing</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">hello</span>()
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Hello</span> <span class="ruby-identifier">there!</span>
</pre>

                              <div class="method-source-code" id="module_exec-source">
            <pre>static VALUE
rb_mod_module_exec_internal(int argc, const VALUE *argv, VALUE mod)
{
    return yield_under(mod, FALSE, argc, argv, RB_PASS_CALLED_KEYWORDS);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Module.html#method-i-class_exec">class_exec</a>
                            </div>

                          </div>

                  <div id="method-i-name" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          name    &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the name of the module <em>mod</em>.  Returns nil for anonymous modules.</p>

                              <div class="method-source-code" id="name-source">
            <pre>VALUE
rb_mod_name(VALUE mod)
{
    bool permanent;
    return classname(mod, &amp;permanent);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-prepend" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          prepend(module, ...)    &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invokes <a href="Module.html#method-i-prepend_features"><code>Module.prepend_features</code></a> on each parameter in reverse order.</p>

                              <div class="method-source-code" id="prepend-source">
            <pre>static VALUE
rb_mod_prepend(int argc, VALUE *argv, VALUE module)
{
    int i;
    ID id_prepend_features, id_prepended;

    if (BUILTIN_TYPE(module) == T_MODULE &amp;&amp; FL_TEST(module, RMODULE_IS_REFINEMENT)) {
        rb_raise(rb_eTypeError, &quot;Refinement#prepend has been removed&quot;);
    }

    CONST_ID(id_prepend_features, &quot;prepend_features&quot;);
    CONST_ID(id_prepended, &quot;prepended&quot;);

    rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
    for (i = 0; i &lt; argc; i++) {
        Check_Type(argv[i], T_MODULE);
        if (FL_TEST(argv[i], RMODULE_IS_REFINEMENT)) {
            rb_raise(rb_eTypeError, &quot;Cannot prepend refinement&quot;);
        }
    }
    while (argc--) {
        rb_funcall(argv[argc], id_prepend_features, 1, module);
        rb_funcall(argv[argc], id_prepended, 1, module);
    }
    return module;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-private_class_method" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          private_class_method(symbol, ...)   &rarr; mod
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          private_class_method(string, ...)   &rarr; mod
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          private_class_method(array)         &rarr; mod
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Makes existing class methods private. Often used to hide the default constructor <code>new</code>.</p>

<p><a href="String.html"><code>String</code></a> arguments are converted to symbols. An <a href="Array.html"><code>Array</code></a> of Symbols and/or Strings is also accepted.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">SimpleSingleton</span>  <span class="ruby-comment"># Not thread safe</span>
  <span class="ruby-identifier">private_class_method</span> <span class="ruby-value">:new</span>
  <span class="ruby-keyword">def</span> <span class="ruby-constant">SimpleSingleton</span>.<span class="ruby-identifier ruby-title">create</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
    <span class="ruby-ivar">@me</span> = <span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-ivar">@me</span>
    <span class="ruby-ivar">@me</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="private_class_method-source">
            <pre>static VALUE
rb_mod_private_method(int argc, VALUE *argv, VALUE obj)
{
    set_method_visibility(rb_singleton_class(obj), argc, argv, METHOD_VISI_PRIVATE);
    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-private_constant" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          private_constant(symbol, ...)    &rarr; mod
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Makes a list of existing constants private.</p>

                              <div class="method-source-code" id="private_constant-source">
            <pre>VALUE
rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj)
{
    set_const_visibility(obj, argc, argv, CONST_PRIVATE, CONST_VISIBILITY_MASK);
    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-private_instance_methods" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          private_instance_methods(include_super=true)    &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a list of the private instance methods defined in <em>mod</em>. If the optional parameter is <code>false</code>, the methods of any ancestors are not included.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Mod</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method1</span>()  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">private</span> <span class="ruby-value">:method1</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method2</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Mod</span>.<span class="ruby-identifier">instance_methods</span>           <span class="ruby-comment">#=&gt; [:method2]</span>
<span class="ruby-constant">Mod</span>.<span class="ruby-identifier">private_instance_methods</span>   <span class="ruby-comment">#=&gt; [:method1]</span>
</pre>

                              <div class="method-source-code" id="private_instance_methods-source">
            <pre>VALUE
rb_class_private_instance_methods(int argc, const VALUE *argv, VALUE mod)
{
    return class_instance_method_list(argc, argv, mod, 0, ins_methods_priv_i);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-private_method_defined-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          private_method_defined?(symbol, inherit=true)    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          private_method_defined?(string, inherit=true)    &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the named private method is defined by <em>mod</em>.  If <em>inherit</em> is set, the lookup will also search <em>mod</em>’s ancestors. <a href="String.html"><code>String</code></a> arguments are converted to symbols.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method1</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">private</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method2</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">C</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method3</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">A</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-value">:method1</span>                   <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">private_method_defined?</span> <span class="ruby-string">&quot;method1&quot;</span>          <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">private_method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>          <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">private_method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>, <span class="ruby-keyword">true</span>    <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">private_method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>, <span class="ruby-keyword">false</span>   <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>                  <span class="ruby-comment">#=&gt; false</span>
</pre>

                              <div class="method-source-code" id="private_method_defined-3F-source">
            <pre>static VALUE
rb_mod_private_method_defined(int argc, VALUE *argv, VALUE mod)
{
    return check_definition(mod, argc, argv, METHOD_VISI_PRIVATE);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-protected_instance_methods" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          protected_instance_methods(include_super=true)   &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a list of the protected instance methods defined in <em>mod</em>. If the optional parameter is <code>false</code>, the methods of any ancestors are not included.</p>

                              <div class="method-source-code" id="protected_instance_methods-source">
            <pre>VALUE
rb_class_protected_instance_methods(int argc, const VALUE *argv, VALUE mod)
{
    return class_instance_method_list(argc, argv, mod, 0, ins_methods_prot_i);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-protected_method_defined-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          protected_method_defined?(symbol, inherit=true)   &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          protected_method_defined?(string, inherit=true)   &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the named protected method is defined <em>mod</em>.  If <em>inherit</em> is set, the lookup will also search <em>mod</em>’s ancestors. <a href="String.html"><code>String</code></a> arguments are converted to symbols.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method1</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">protected</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method2</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">C</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method3</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">A</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-value">:method1</span>                    <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">protected_method_defined?</span> <span class="ruby-string">&quot;method1&quot;</span>         <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">protected_method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>         <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">protected_method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>, <span class="ruby-keyword">true</span>   <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">protected_method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>, <span class="ruby-keyword">false</span>  <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>                   <span class="ruby-comment">#=&gt; true</span>
</pre>

                              <div class="method-source-code" id="protected_method_defined-3F-source">
            <pre>static VALUE
rb_mod_protected_method_defined(int argc, VALUE *argv, VALUE mod)
{
    return check_definition(mod, argc, argv, METHOD_VISI_PROTECTED);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-public_class_method" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          public_class_method(symbol, ...)    &rarr; mod
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          public_class_method(string, ...)    &rarr; mod
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          public_class_method(array)          &rarr; mod
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Makes a list of existing class methods public.</p>

<p><a href="String.html"><code>String</code></a> arguments are converted to symbols. An <a href="Array.html"><code>Array</code></a> of Symbols and/or Strings is also accepted.</p>

                              <div class="method-source-code" id="public_class_method-source">
            <pre>static VALUE
rb_mod_public_method(int argc, VALUE *argv, VALUE obj)
{
    set_method_visibility(rb_singleton_class(obj), argc, argv, METHOD_VISI_PUBLIC);
    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-public_constant" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          public_constant(symbol, ...)    &rarr; mod
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Makes a list of existing constants public.</p>

                              <div class="method-source-code" id="public_constant-source">
            <pre>VALUE
rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj)
{
    set_const_visibility(obj, argc, argv, CONST_PUBLIC, CONST_VISIBILITY_MASK);
    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-public_instance_method" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          public_instance_method(symbol)   &rarr; unbound_method
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Similar to <em>instance_method</em>, searches public method only.</p>

                              <div class="method-source-code" id="public_instance_method-source">
            <pre>static VALUE
rb_mod_public_instance_method(VALUE mod, VALUE vid)
{
    ID id = rb_check_id(&amp;vid);
    if (!id) {
        rb_method_name_error(mod, vid);
    }
    return mnew_unbound(mod, id, rb_cUnboundMethod, TRUE);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-public_instance_methods" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          public_instance_methods(include_super=true)   &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a list of the public instance methods defined in <em>mod</em>. If the optional parameter is <code>false</code>, the methods of any ancestors are not included.</p>

                              <div class="method-source-code" id="public_instance_methods-source">
            <pre>VALUE
rb_class_public_instance_methods(int argc, const VALUE *argv, VALUE mod)
{
    return class_instance_method_list(argc, argv, mod, 0, ins_methods_pub_i);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-public_method_defined-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          public_method_defined?(symbol, inherit=true)   &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          public_method_defined?(string, inherit=true)   &rarr; true or false
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the named public method is defined by <em>mod</em>.  If <em>inherit</em> is set, the lookup will also search <em>mod</em>’s ancestors. <a href="String.html"><code>String</code></a> arguments are converted to symbols.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method1</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">protected</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method2</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">C</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">B</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">method3</span>()  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-constant">A</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-value">:method1</span>                 <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">public_method_defined?</span> <span class="ruby-string">&quot;method1&quot;</span>         <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">public_method_defined?</span> <span class="ruby-string">&quot;method1&quot;</span>, <span class="ruby-keyword">true</span>   <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">public_method_defined?</span> <span class="ruby-string">&quot;method1&quot;</span>, <span class="ruby-keyword">false</span>  <span class="ruby-comment">#=&gt; true</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">public_method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>         <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-string">&quot;method2&quot;</span>                <span class="ruby-comment">#=&gt; true</span>
</pre>

                              <div class="method-source-code" id="public_method_defined-3F-source">
            <pre>static VALUE
rb_mod_public_method_defined(int argc, VALUE *argv, VALUE mod)
{
    return check_definition(mod, argc, argv, METHOD_VISI_PUBLIC);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-refinements" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          refinements &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of modules defined within the receiver.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-identifier">refine</span> <span class="ruby-constant">Integer</span> <span class="ruby-keyword">do</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">refine</span> <span class="ruby-constant">String</span> <span class="ruby-keyword">do</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">p</span> <span class="ruby-constant">A</span>.<span class="ruby-identifier">refinements</span>
</pre>

<p><em>produces:</em></p>

<pre>[#&lt;refinement:Integer@A&gt;, #&lt;refinement:String@A&gt;]</pre>

                              <div class="method-source-code" id="refinements-source">
            <pre>static VALUE
mod_refinements(VALUE self)
{
    ID id_refinements;
    VALUE refinements;

    CONST_ID(id_refinements, &quot;__refinements__&quot;);
    refinements = rb_attr_get(self, id_refinements);
    if (NIL_P(refinements)) {
        return rb_ary_new();
    }
    return rb_hash_values(refinements);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_class_variable" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          remove_class_variable(sym)    &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes the named class variable from the receiver, returning that variable’s value.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Example</span>
  <span class="ruby-identifier">@@var</span> = <span class="ruby-value">99</span>
  <span class="ruby-identifier">puts</span> <span class="ruby-identifier">remove_class_variable</span>(<span class="ruby-value">:@@var</span>)
  <span class="ruby-identifier">p</span>(<span class="ruby-keyword">defined?</span> <span class="ruby-identifier">@@var</span>)
<span class="ruby-keyword">end</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-value">99</span>
<span class="ruby-keyword">nil</span>
</pre>

                              <div class="method-source-code" id="remove_class_variable-source">
            <pre>VALUE
rb_mod_remove_cvar(VALUE mod, VALUE name)
{
    const ID id = id_for_var_message(mod, name, class, &quot;wrong class variable name %1$s&quot;);
    st_data_t val;

    if (!id) {
        goto not_defined;
    }
    rb_check_frozen(mod);
    val = rb_ivar_delete(mod, id, Qundef);
    if (!UNDEF_P(val)) {
        return (VALUE)val;
    }
    if (rb_cvar_defined(mod, id)) {
        rb_name_err_raise(&quot;cannot remove %1$s for %2$s&quot;, mod, ID2SYM(id));
    }
  not_defined:
    rb_name_err_raise(&quot;class variable %1$s not defined for %2$s&quot;,
                      mod, name);
    UNREACHABLE_RETURN(Qundef);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_method" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          remove_method(symbol)   &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          remove_method(string)   &rarr; self
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Removes the method identified by <em>symbol</em> from the current class. For an example, see <a href="Module.html#method-i-undef_method"><code>Module#undef_method</code></a>. <a href="String.html"><code>String</code></a> arguments are converted to symbols.</p>

                              <div class="method-source-code" id="remove_method-source">
            <pre>static VALUE
rb_mod_remove_method(int argc, VALUE *argv, VALUE mod)
{
    int i;

    for (i = 0; i &lt; argc; i++) {
        VALUE v = argv[i];
        ID id = rb_check_id(&amp;v);
        if (!id) {
            rb_name_err_raise(&quot;method `%1$s&#39; not defined in %2$s&quot;,
                              mod, v);
        }
        remove_method(mod, id);
    }
    return mod;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_temporary_name" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          set_temporary_name(string) &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          set_temporary_name(nil) &rarr; self
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Sets the temporary name of the module <code>mod</code>. This name is used as a prefix for the names of constants declared in <code>mod</code>. If the module is assigned a permanent name, the temporary name is discarded.</p>

<p>After a permanent name is assigned, a temporary name can no longer be set, and this method raises a <a href="RuntimeError.html"><code>RuntimeError</code></a>.</p>

<p>If the name given is not a string or is a zero length string, this method raises an <a href="ArgumentError.html"><code>ArgumentError</code></a>.</p>

<p>The temporary name must not be a valid constant name, to avoid confusion with actual constants. If you attempt to set a temporary name that is a a valid constant name, this method raises an <a href="ArgumentError.html"><code>ArgumentError</code></a>.</p>

<p>If the given name is <code>nil</code>, the module becomes anonymous.</p>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-constant">Module</span>.<span class="ruby-identifier">new</span> <span class="ruby-comment"># =&gt; #&lt;Module:0x0000000102c68f38&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">name</span> <span class="ruby-comment">#=&gt; nil</span>

<span class="ruby-identifier">m</span>.<span class="ruby-identifier">set_temporary_name</span>(<span class="ruby-string">&quot;fake_name&quot;</span>) <span class="ruby-comment"># =&gt; fake_name</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">name</span> <span class="ruby-comment">#=&gt; &quot;fake_name&quot;</span>

<span class="ruby-identifier">m</span>.<span class="ruby-identifier">set_temporary_name</span>(<span class="ruby-keyword">nil</span>) <span class="ruby-comment"># =&gt; #&lt;Module:0x0000000102c68f38&gt;</span>
<span class="ruby-identifier">m</span>.<span class="ruby-identifier">name</span> <span class="ruby-comment">#=&gt; nil</span>

<span class="ruby-identifier">n</span> = <span class="ruby-constant">Module</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">n</span>.<span class="ruby-identifier">set_temporary_name</span>(<span class="ruby-string">&quot;fake_name&quot;</span>)

<span class="ruby-identifier">n</span><span class="ruby-operator">::</span><span class="ruby-constant">M</span> = <span class="ruby-identifier">m</span>
<span class="ruby-identifier">n</span><span class="ruby-operator">::</span><span class="ruby-constant">M</span>.<span class="ruby-identifier">name</span> <span class="ruby-comment">#=&gt; &quot;fake_name::M&quot;</span>
<span class="ruby-constant">N</span> = <span class="ruby-identifier">n</span>

<span class="ruby-constant">N</span>.<span class="ruby-identifier">name</span> <span class="ruby-comment">#=&gt; &quot;nested_fake_name&quot;</span>
<span class="ruby-constant">N</span><span class="ruby-operator">::</span><span class="ruby-constant">M</span>.<span class="ruby-identifier">name</span> <span class="ruby-comment">#=&gt; &quot;N::M&quot;</span>
</pre>

                              <div class="method-source-code" id="set_temporary_name-source">
            <pre>VALUE
rb_mod_set_temporary_name(VALUE mod, VALUE name)
{
    // We don&#39;t allow setting the name if the classpath is already permanent:
    if (RCLASS_EXT(mod)-&gt;permanent_classpath) {
        rb_raise(rb_eRuntimeError, &quot;can&#39;t change permanent name&quot;);
    }

    if (NIL_P(name)) {
        // Set the temporary classpath to NULL (anonymous):
        RCLASS_SET_CLASSPATH(mod, 0, FALSE);
    } else {
        // Ensure the name is a string:
        StringValue(name);

        if (RSTRING_LEN(name) == 0) {
            rb_raise(rb_eArgError, &quot;empty class/module name&quot;);
        }

        if (is_constant_path(name)) {
            rb_raise(rb_eArgError, &quot;the temporary name must not be a constant path to avoid confusion&quot;);
        }

        // Set the temporary classpath to the given name:
        RCLASS_SET_CLASSPATH(mod, name, FALSE);
    }

    return mod;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-singleton_class-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          singleton_class?    &rarr; true or false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <em>mod</em> is a singleton class or <code>false</code> if it is an ordinary class or module.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">C</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">singleton_class?</span>                  <span class="ruby-comment">#=&gt; false</span>
<span class="ruby-constant">C</span>.<span class="ruby-identifier">singleton_class</span>.<span class="ruby-identifier">singleton_class?</span>  <span class="ruby-comment">#=&gt; true</span>
</pre>

                              <div class="method-source-code" id="singleton_class-3F-source">
            <pre>static VALUE
rb_mod_singleton_p(VALUE klass)
{
    return RBOOL(RB_TYPE_P(klass, T_CLASS) &amp;&amp; FL_TEST(klass, FL_SINGLETON));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_s" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_s   &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string representing this module or class. For basic classes and modules, this is the name. For singletons, we show information on the thing we’re attached to as well.</p>

                              <div class="method-source-code" id="to_s-source">
            <pre>VALUE
rb_mod_to_s(VALUE klass)
{
    ID id_defined_at;
    VALUE refined_class, defined_at;

    if (FL_TEST(klass, FL_SINGLETON)) {
        VALUE s = rb_usascii_str_new2(&quot;#&lt;Class:&quot;);
        VALUE v = RCLASS_ATTACHED_OBJECT(klass);

        if (CLASS_OR_MODULE_P(v)) {
            rb_str_append(s, rb_inspect(v));
        }
        else {
            rb_str_append(s, rb_any_to_s(v));
        }
        rb_str_cat2(s, &quot;&gt;&quot;);

        return s;
    }
    refined_class = rb_refinement_module_get_refined_class(klass);
    if (!NIL_P(refined_class)) {
        VALUE s = rb_usascii_str_new2(&quot;#&lt;refinement:&quot;);

        rb_str_concat(s, rb_inspect(refined_class));
        rb_str_cat2(s, &quot;@&quot;);
        CONST_ID(id_defined_at, &quot;__defined_at__&quot;);
        defined_at = rb_attr_get(klass, id_defined_at);
        rb_str_concat(s, rb_inspect(defined_at));
        rb_str_cat2(s, &quot;&gt;&quot;);
        return s;
    }
    return rb_class_name(klass);
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Module.html#method-i-inspect">inspect</a>
                            </div>

                          </div>

                  <div id="method-i-undef_method" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          undef_method(symbol)    &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          undef_method(string)    &rarr; self
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Prevents the current class from responding to calls to the named method. Contrast this with <code>remove_method</code>, which deletes the method from the particular class; Ruby will still search superclasses and mixed-in modules for a possible receiver. <a href="String.html"><code>String</code></a> arguments are converted to symbols.</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Parent</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hello</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;In parent&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">Child</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Parent</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hello</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;In child&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">c</span> = <span class="ruby-constant">Child</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">c</span>.<span class="ruby-identifier">hello</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">Child</span>
  <span class="ruby-identifier">remove_method</span> <span class="ruby-value">:hello</span>  <span class="ruby-comment"># remove from child, still in parent</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">c</span>.<span class="ruby-identifier">hello</span>

<span class="ruby-keyword">class</span> <span class="ruby-constant">Child</span>
  <span class="ruby-identifier">undef_method</span> <span class="ruby-value">:hello</span>   <span class="ruby-comment"># prevent any calls to &#39;hello&#39;</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">c</span>.<span class="ruby-identifier">hello</span>
</pre>

<p><em>produces:</em></p>

<pre>In child
In parent
prog.rb:23: undefined method `hello&#39; for #&lt;Child:0x401b3bb4&gt; (NoMethodError)</pre>

                              <div class="method-source-code" id="undef_method-source">
            <pre>static VALUE
rb_mod_undef_method(int argc, VALUE *argv, VALUE mod)
{
    int i;
    for (i = 0; i &lt; argc; i++) {
        VALUE v = argv[i];
        ID id = rb_check_id(&amp;v);
        if (!id) {
            rb_method_name_error(mod, v);
        }
        rb_undef(mod, id);
    }
    return mod;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-undefined_instance_methods" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          undefined_instance_methods   &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a list of the undefined instance methods defined in <em>mod</em>. The undefined methods of any ancestors are not included.</p>

                              <div class="method-source-code" id="undefined_instance_methods-source">
            <pre>VALUE
rb_class_undefined_instance_methods(VALUE mod)
{
    VALUE include_super = Qfalse;
    return class_instance_method_list(1, &amp;include_super, mod, 0, ins_methods_undef_i);
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-append_features" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          append_features(mod)   &rarr; mod
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>When this module is included in another, Ruby calls <a href="Module.html#method-i-append_features"><code>append_features</code></a> in this module, passing it the receiving module in <em>mod</em>. Ruby’s default implementation is to add the constants, methods, and module variables of this module to <em>mod</em> if this module has not already been added to <em>mod</em> or one of its ancestors. See also <a href="Module.html#method-i-include"><code>Module#include</code></a>.</p>

                              <div class="method-source-code" id="append_features-source">
            <pre>static VALUE
rb_mod_append_features(VALUE module, VALUE include)
{
    if (!CLASS_OR_MODULE_P(include)) {
        Check_Type(include, T_CLASS);
    }
    rb_include_module(include, module);

    return module;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-const_added" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          const_added(const_name)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invoked as a callback whenever a constant is assigned on the receiver</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Chatty</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">const_added</span>(<span class="ruby-identifier">const_name</span>)
    <span class="ruby-keyword">super</span>
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Added #{const_name.inspect}&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-constant">FOO</span> = <span class="ruby-value">1</span>
<span class="ruby-keyword">end</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Added</span> <span class="ruby-value">:FOO</span>
</pre>

                              <div class="method-source-code" id="const_added-source">
            <pre>#define rb_obj_mod_const_added rb_obj_dummy1</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-extend_object" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          extend_object(obj)    &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Extends the specified object by adding this module’s constants and methods (which are added as singleton methods). This is the callback method used by <a href="Object.html#method-i-extend"><code>Object#extend</code></a>.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Picky</span>
  <span class="ruby-keyword">def</span> <span class="ruby-constant">Picky</span>.<span class="ruby-identifier ruby-title">extend_object</span>(<span class="ruby-identifier">o</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">o</span>
      <span class="ruby-identifier">puts</span> <span class="ruby-string">&quot;Can&#39;t add Picky to a String&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Picky added to #{o.class}&quot;</span>
      <span class="ruby-keyword">super</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
(<span class="ruby-identifier">s</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>).<span class="ruby-identifier">extend</span> <span class="ruby-constant">Picky</span>  <span class="ruby-comment"># Call Object.extend</span>
(<span class="ruby-identifier">s</span> = <span class="ruby-string">&quot;quick brown fox&quot;</span>).<span class="ruby-identifier">extend</span> <span class="ruby-constant">Picky</span>
</pre>

<p><em>produces:</em></p>

<pre>Picky added to Array
Can&#39;t add Picky to a String</pre>

                              <div class="method-source-code" id="extend_object-source">
            <pre>static VALUE
rb_mod_extend_object(VALUE mod, VALUE obj)
{
    rb_extend_object(obj, mod);
    return obj;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-extended" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          extended(othermod)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The equivalent of <code>included</code>, but for extended modules.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">extended</span>(<span class="ruby-identifier">mod</span>)
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{self} extended in #{mod}&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">module</span> <span class="ruby-constant">Enumerable</span>
  <span class="ruby-identifier">extend</span> <span class="ruby-constant">A</span>
<span class="ruby-keyword">end</span>
 <span class="ruby-comment"># =&gt; prints &quot;A extended in Enumerable&quot;</span>
</pre>

                              <div class="method-source-code" id="extended-source">
            <pre>#define rb_obj_mod_extended rb_obj_dummy1</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-included" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          included(othermod)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Callback invoked whenever the receiver is included in another module or class. This should be used in preference to <code>Module.append_features</code> if your code wants to perform some action when a module is included in another.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-constant">A</span>.<span class="ruby-identifier ruby-title">included</span>(<span class="ruby-identifier">mod</span>)
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{self} included in #{mod}&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">module</span> <span class="ruby-constant">Enumerable</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">A</span>
<span class="ruby-keyword">end</span>
 <span class="ruby-comment"># =&gt; prints &quot;A included in Enumerable&quot;</span>
</pre>

                              <div class="method-source-code" id="included-source">
            <pre>#define rb_obj_mod_included rb_obj_dummy1</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-method_added" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          method_added(method_name)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invoked as a callback whenever an instance method is added to the receiver.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Chatty</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">method_added</span>(<span class="ruby-identifier">method_name</span>)
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Adding #{method_name.inspect}&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">some_class_method</span>() <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">some_instance_method</span>() <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Adding</span> <span class="ruby-value">:some_instance_method</span>
</pre>

                              <div class="method-source-code" id="method_added-source">
            <pre>#define rb_obj_mod_method_added rb_obj_dummy1</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-method_removed" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          method_removed(method_name)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invoked as a callback whenever an instance method is removed from the receiver.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Chatty</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">method_removed</span>(<span class="ruby-identifier">method_name</span>)
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Removing #{method_name.inspect}&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">some_class_method</span>() <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">some_instance_method</span>() <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">class</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">self</span>
    <span class="ruby-identifier">remove_method</span> <span class="ruby-value">:some_class_method</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">remove_method</span> <span class="ruby-value">:some_instance_method</span>
<span class="ruby-keyword">end</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Removing</span> <span class="ruby-value">:some_instance_method</span>
</pre>

                              <div class="method-source-code" id="method_removed-source">
            <pre>#define rb_obj_mod_method_removed rb_obj_dummy1</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-method_undefined" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          method_undefined(method_name)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Invoked as a callback whenever an instance method is undefined from the receiver.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Chatty</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">method_undefined</span>(<span class="ruby-identifier">method_name</span>)
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Undefining #{method_name.inspect}&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">some_class_method</span>() <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">some_instance_method</span>() <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">class</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">self</span>
    <span class="ruby-identifier">undef_method</span> <span class="ruby-value">:some_class_method</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">undef_method</span> <span class="ruby-value">:some_instance_method</span>
<span class="ruby-keyword">end</span>
</pre>

<p><em>produces:</em></p>

<pre class="ruby"><span class="ruby-constant">Undefining</span> <span class="ruby-value">:some_instance_method</span>
</pre>

                              <div class="method-source-code" id="method_undefined-source">
            <pre>#define rb_obj_mod_method_undefined rb_obj_dummy1</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-module_function" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          module_function                                &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          module_function(method_name)                   &rarr; method_name
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          module_function(method_name, method_name, ...) &rarr; array
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Creates module functions for the named methods. These functions may be called with the module as a receiver, and also become available as instance methods to classes that mix in the module. <a href="Module.html"><code>Module</code></a> functions are copies of the original, and so may be changed independently. The instance-method versions are made private. If used with no arguments, subsequently defined methods become module functions. <a href="String.html"><code>String</code></a> arguments are converted to symbols. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Mod</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">one</span>
    <span class="ruby-string">&quot;This is one&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">module_function</span> <span class="ruby-value">:one</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">class</span> <span class="ruby-constant">Cls</span>
  <span class="ruby-identifier">include</span> <span class="ruby-constant">Mod</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">call_one</span>
    <span class="ruby-identifier">one</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Mod</span>.<span class="ruby-identifier">one</span>     <span class="ruby-comment">#=&gt; &quot;This is one&quot;</span>
<span class="ruby-identifier">c</span> = <span class="ruby-constant">Cls</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">c</span>.<span class="ruby-identifier">call_one</span>  <span class="ruby-comment">#=&gt; &quot;This is one&quot;</span>
<span class="ruby-keyword">module</span> <span class="ruby-constant">Mod</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">one</span>
    <span class="ruby-string">&quot;This is the new one&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Mod</span>.<span class="ruby-identifier">one</span>     <span class="ruby-comment">#=&gt; &quot;This is one&quot;</span>
<span class="ruby-identifier">c</span>.<span class="ruby-identifier">call_one</span>  <span class="ruby-comment">#=&gt; &quot;This is the new one&quot;</span>
</pre>

                              <div class="method-source-code" id="module_function-source">
            <pre>static VALUE
rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
{
    int i;
    ID id;
    const rb_method_entry_t *me;

    if (!RB_TYPE_P(module, T_MODULE)) {
        rb_raise(rb_eTypeError, &quot;module_function must be called for modules&quot;);
    }

    if (argc == 0) {
        rb_scope_module_func_set();
        return Qnil;
    }

    set_method_visibility(module, argc, argv, METHOD_VISI_PRIVATE);

    for (i = 0; i &lt; argc; i++) {
        VALUE m = module;

        id = rb_to_id(argv[i]);
        for (;;) {
            me = search_method(m, id, 0);
            if (me == 0) {
                me = search_method(rb_cObject, id, 0);
            }
            if (UNDEFINED_METHOD_ENTRY_P(me)) {
                rb_print_undef(module, id, METHOD_VISI_UNDEF);
            }
            if (me-&gt;def-&gt;type != VM_METHOD_TYPE_ZSUPER) {
                break; /* normal case: need not to follow &#39;super&#39; link */
            }
            m = RCLASS_SUPER(m);
            if (!m)
                break;
        }
        rb_method_entry_set(rb_singleton_class(module), id, me, METHOD_VISI_PUBLIC);
    }
    if (argc == 1) {
        return argv[0];
    }
    return rb_ary_new_from_values(argc, argv);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-prepend_features" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          prepend_features(mod)   &rarr; mod
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>When this module is prepended in another, Ruby calls <a href="Module.html#method-i-prepend_features"><code>prepend_features</code></a> in this module, passing it the receiving module in <em>mod</em>. Ruby’s default implementation is to overlay the constants, methods, and module variables of this module to <em>mod</em> if this module has not already been added to <em>mod</em> or one of its ancestors. See also <a href="Module.html#method-i-prepend"><code>Module#prepend</code></a>.</p>

                              <div class="method-source-code" id="prepend_features-source">
            <pre>static VALUE
rb_mod_prepend_features(VALUE module, VALUE prepend)
{
    if (!CLASS_OR_MODULE_P(prepend)) {
        Check_Type(prepend, T_CLASS);
    }
    rb_prepend_module(prepend, module);

    return module;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-prepended" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          prepended(othermod)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The equivalent of <code>included</code>, but for prepended modules.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">A</span>
  <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">prepended</span>(<span class="ruby-identifier">mod</span>)
    <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{self} prepended to #{mod}&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">module</span> <span class="ruby-constant">Enumerable</span>
  <span class="ruby-identifier">prepend</span> <span class="ruby-constant">A</span>
<span class="ruby-keyword">end</span>
 <span class="ruby-comment"># =&gt; prints &quot;A prepended to Enumerable&quot;</span>
</pre>

                              <div class="method-source-code" id="prepended-source">
            <pre>#define rb_obj_mod_prepended rb_obj_dummy1</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-private" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          private                                &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          private(method_name)                   &rarr; method_name
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          private(method_name, method_name, ...) &rarr; array
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          private(array)                         &rarr; array
                              </span>
                            </div>

                            <div class="method-description">
                              <p>With no arguments, sets the default visibility for subsequently defined methods to private. With arguments, sets the named methods to have private visibility. <a href="String.html"><code>String</code></a> arguments are converted to symbols. An <a href="Array.html"><code>Array</code></a> of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array.</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Mod</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">a</span>()  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">b</span>()  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">private</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">c</span>()  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">private</span> <span class="ruby-value">:a</span>
<span class="ruby-keyword">end</span>
<span class="ruby-constant">Mod</span>.<span class="ruby-identifier">private_instance_methods</span>   <span class="ruby-comment">#=&gt; [:a, :c]</span>
</pre>

<p>Note that to show a private method on <a href="RDoc.html"><code>RDoc</code></a>, use <code>:doc:</code>.</p>

                              <div class="method-source-code" id="private-source">
            <pre>static VALUE
rb_mod_private(int argc, VALUE *argv, VALUE module)
{
    return set_visibility(argc, argv, module, METHOD_VISI_PRIVATE);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-protected" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          protected                                &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          protected(method_name)                   &rarr; method_name
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          protected(method_name, method_name, ...) &rarr; array
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          protected(array)                         &rarr; array
                              </span>
                            </div>

                            <div class="method-description">
                              <p>With no arguments, sets the default visibility for subsequently defined methods to protected. With arguments, sets the named methods to have protected visibility. <a href="String.html"><code>String</code></a> arguments are converted to symbols. An <a href="Array.html"><code>Array</code></a> of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array.</p>

<p>If a method has protected visibility, it is callable only where <code>self</code> of the context is the same as the method. (method definition or instance_eval). This behavior is different from Java’s protected method. Usually <code>private</code> should be used.</p>

<p>Note that a protected method is slow because it can’t use inline cache.</p>

<p>To show a private method on <a href="RDoc.html"><code>RDoc</code></a>, use <code>:doc:</code> instead of this.</p>

                              <div class="method-source-code" id="protected-source">
            <pre>static VALUE
rb_mod_protected(int argc, VALUE *argv, VALUE module)
{
    return set_visibility(argc, argv, module, METHOD_VISI_PROTECTED);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-public" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          public                                &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          public(method_name)                   &rarr; method_name
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          public(method_name, method_name, ...) &rarr; array
                              </span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          public(array)                         &rarr; array
                              </span>
                            </div>

                            <div class="method-description">
                              <p>With no arguments, sets the default visibility for subsequently defined methods to public. With arguments, sets the named methods to have public visibility. <a href="String.html"><code>String</code></a> arguments are converted to symbols. An <a href="Array.html"><code>Array</code></a> of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array.</p>

                              <div class="method-source-code" id="public-source">
            <pre>static VALUE
rb_mod_public(int argc, VALUE *argv, VALUE module)
{
    return set_visibility(argc, argv, module, METHOD_VISI_PUBLIC);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-refine" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          refine(mod) { block }   &rarr; module
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Refine <em>mod</em> in the receiver.</p>

<p>Returns a module, where refined methods are defined.</p>

                              <div class="method-source-code" id="refine-source">
            <pre>static VALUE
rb_mod_refine(VALUE module, VALUE klass)
{
    VALUE refinement;
    ID id_refinements, id_activated_refinements,
       id_refined_class, id_defined_at;
    VALUE refinements, activated_refinements;
    rb_thread_t *th = GET_THREAD();
    VALUE block_handler = rb_vm_frame_block_handler(th-&gt;ec-&gt;cfp);

    if (block_handler == VM_BLOCK_HANDLER_NONE) {
        rb_raise(rb_eArgError, &quot;no block given&quot;);
    }
    if (vm_block_handler_type(block_handler) != block_handler_type_iseq) {
        rb_raise(rb_eArgError, &quot;can&#39;t pass a Proc as a block to Module#refine&quot;);
    }

    ensure_class_or_module(klass);
    CONST_ID(id_refinements, &quot;__refinements__&quot;);
    refinements = rb_attr_get(module, id_refinements);
    if (NIL_P(refinements)) {
        refinements = hidden_identity_hash_new();
        rb_ivar_set(module, id_refinements, refinements);
    }
    CONST_ID(id_activated_refinements, &quot;__activated_refinements__&quot;);
    activated_refinements = rb_attr_get(module, id_activated_refinements);
    if (NIL_P(activated_refinements)) {
        activated_refinements = hidden_identity_hash_new();
        rb_ivar_set(module, id_activated_refinements,
                    activated_refinements);
    }
    refinement = rb_hash_lookup(refinements, klass);
    if (NIL_P(refinement)) {
        VALUE superclass = refinement_superclass(klass);
        refinement = rb_refinement_new();
        RCLASS_SET_SUPER(refinement, superclass);
        RUBY_ASSERT(BUILTIN_TYPE(refinement) == T_MODULE);
        FL_SET(refinement, RMODULE_IS_REFINEMENT);
        CONST_ID(id_refined_class, &quot;__refined_class__&quot;);
        rb_ivar_set(refinement, id_refined_class, klass);
        CONST_ID(id_defined_at, &quot;__defined_at__&quot;);
        rb_ivar_set(refinement, id_defined_at, module);
        rb_hash_aset(refinements, klass, refinement);
        add_activated_refinement(activated_refinements, klass, refinement);
    }
    rb_yield_refine_block(refinement, activated_refinements);
    return refinement;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_const" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          remove_const(sym)   &rarr; obj
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes the definition of the given constant, returning that constant’s previous value.  If that constant referred to a module, this will not change that module’s name and can lead to confusion.</p>

                              <div class="method-source-code" id="remove_const-source">
            <pre>VALUE
rb_mod_remove_const(VALUE mod, VALUE name)
{
    const ID id = id_for_var(mod, name, a, constant);

    if (!id) {
        undefined_constant(mod, name);
    }
    return rb_const_remove(mod, id);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-ruby2_keywords" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          ruby2_keywords(method_name, ...)    &rarr; nil
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>For the given method names, marks the method as passing keywords through a normal argument splat.  This should only be called on methods that accept an argument splat (<code>*args</code>) but not explicit keywords or a keyword splat.  It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.</p>

<p>This should only be used for methods that delegate keywords to another method, and only for backwards compatibility with Ruby versions before 3.0. See <a href="https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0">www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0</a>/ for details on why <code>ruby2_keywords</code> exists and when and how to use it.</p>

<p>This method will probably be removed at some point, as it exists only for backwards compatibility. As it does not exist in Ruby versions before 2.7, check that the module responds to this method before calling it:</p>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">Mod</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">foo</span>(<span class="ruby-identifier">meth</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
    <span class="ruby-identifier">send</span>(<span class="ruby-value">:&quot;do_#{meth}&quot;</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ruby2_keywords</span>(<span class="ruby-value">:foo</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:ruby2_keywords</span>, <span class="ruby-keyword">true</span>)
<span class="ruby-keyword">end</span>
</pre>

<p>However, be aware that if the <code>ruby2_keywords</code> method is removed, the behavior of the <code>foo</code> method using the above approach will change so that the method does not pass through keywords.</p>

                              <div class="method-source-code" id="ruby2_keywords-source">
            <pre>static VALUE
rb_mod_ruby2_keywords(int argc, VALUE *argv, VALUE module)
{
    int i;
    VALUE origin_class = RCLASS_ORIGIN(module);

    rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
    rb_check_frozen(module);

    for (i = 0; i &lt; argc; i++) {
        VALUE v = argv[i];
        ID name = rb_check_id(&amp;v);
        rb_method_entry_t *me;
        VALUE defined_class;

        if (!name) {
            rb_print_undef_str(module, v);
        }

        me = search_method(origin_class, name, &amp;defined_class);
        if (!me &amp;&amp; RB_TYPE_P(module, T_MODULE)) {
            me = search_method(rb_cObject, name, &amp;defined_class);
        }

        if (UNDEFINED_METHOD_ENTRY_P(me) ||
            UNDEFINED_REFINED_METHOD_P(me-&gt;def)) {
            rb_print_undef(module, name, METHOD_VISI_UNDEF);
        }

        if (module == defined_class || origin_class == defined_class) {
            switch (me-&gt;def-&gt;type) {
              case VM_METHOD_TYPE_ISEQ:
                if (ISEQ_BODY(me-&gt;def-&gt;body.iseq.iseqptr)-&gt;param.flags.has_rest &amp;&amp;
                        !ISEQ_BODY(me-&gt;def-&gt;body.iseq.iseqptr)-&gt;param.flags.has_kw &amp;&amp;
                        !ISEQ_BODY(me-&gt;def-&gt;body.iseq.iseqptr)-&gt;param.flags.has_kwrest) {
                    ISEQ_BODY(me-&gt;def-&gt;body.iseq.iseqptr)-&gt;param.flags.ruby2_keywords = 1;
                    rb_clear_method_cache(module, name);
                }
                else {
                    rb_warn(&quot;Skipping set of ruby2_keywords flag for %s (method accepts keywords or method does not accept argument splat)&quot;, rb_id2name(name));
                }
                break;
              case VM_METHOD_TYPE_BMETHOD: {
                VALUE procval = me-&gt;def-&gt;body.bmethod.proc;
                if (vm_block_handler_type(procval) == block_handler_type_proc) {
                    procval = vm_proc_to_block_handler(VM_BH_TO_PROC(procval));
                }

                if (vm_block_handler_type(procval) == block_handler_type_iseq) {
                    const struct rb_captured_block *captured = VM_BH_TO_ISEQ_BLOCK(procval);
                    const rb_iseq_t *iseq = rb_iseq_check(captured-&gt;code.iseq);
                    if (ISEQ_BODY(iseq)-&gt;param.flags.has_rest &amp;&amp;
                            !ISEQ_BODY(iseq)-&gt;param.flags.has_kw &amp;&amp;
                            !ISEQ_BODY(iseq)-&gt;param.flags.has_kwrest) {
                        ISEQ_BODY(iseq)-&gt;param.flags.ruby2_keywords = 1;
                        rb_clear_method_cache(module, name);
                    }
                    else {
                        rb_warn(&quot;Skipping set of ruby2_keywords flag for %s (method accepts keywords or method does not accept argument splat)&quot;, rb_id2name(name));
                    }
                    break;
                }
              }
              /* fallthrough */
              default:
                rb_warn(&quot;Skipping set of ruby2_keywords flag for %s (method not defined in Ruby)&quot;, rb_id2name(name));
                break;
            }
        }
        else {
            rb_warn(&quot;Skipping set of ruby2_keywords flag for %s (can only set in method defining module)&quot;, rb_id2name(name));
        }
    }
    return Qnil;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-using" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          using(module)    &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Import class refinements from <em>module</em> into the current class or module definition.</p>

                              <div class="method-source-code" id="using-source">
            <pre>static VALUE
mod_using(VALUE self, VALUE module)
{
    rb_control_frame_t *prev_cfp = previous_frame(GET_EC());

    if (prev_frame_func()) {
        rb_raise(rb_eRuntimeError,
                 &quot;Module#using is not permitted in methods&quot;);
    }
    if (prev_cfp &amp;&amp; prev_cfp-&gt;self != self) {
        rb_raise(rb_eRuntimeError, &quot;Module#using is not called on self&quot;);
    }
    if (rb_block_given_p()) {
        ignored_block(module, &quot;Module#&quot;);
    }
    rb_using_module(rb_vm_cref_replace_with_duplicated_cref(), module);
    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

